![]() ![]() The xtable package to produce nice tables in a PDFĪgain, we find ourselves using the extremely helpful dplyr package to answer this question and to create the underpinnings of our table to display. ![]() If you click on the max_delay column header, you should see that the maximum departure delay for PDX was in March and for Seattle was in May. The created table in HTML is available here. (An excellent tutorial on DT is available at. Go ahead and play around with the filter boxes at the top of each column too. I’ve specified a few extra options here to show all 12 months by default and to automatically set the width. The DT package provides a nice interface for viewing data frames in R. Summarize(max_delay = max(dep_delay, na.rm = TRUE)) dep_delays_by_month % group_by(origin, month) %>% In order to answer the second question, we’ll again make use of the various functions in the dplyr package. Surprisingly, the airport in Bellingham, WA (only around 100 miles north of SEA) had the fifth largest mean arrival delay. ![]() Houston also had around a 10 minute delay on average. Oddly enough, flights to Cleveland (from PDX and SEA) had the worst arrival delays in 2014. Lastly we output this table cleanly using the kable function. Rename("Airport Name" = name, "Airport Code" = dest, "Mean Arrival Delay" = mean_arr_delay) data("airports", package = "pnwflights14") Here we will do a match to identify the names of these airports using the inner_join function in dplyr. One of the other data sets included in the pnwflights14 package is airports that lists the names. This information is helpful but you may not necessarily know to which airport each of these FAA airport codes refers. Summarize(mean_arr_delay = mean(arr_delay, na.rm = TRUE)) %>% # List of packages required for this analysis We begin by ensuring the needed packages are installed and then load them into our R session. (More information and the source code for this R package is available at. In what follows, I’ll discuss these different options using data on departing flights from Seattle and Portland in 2014. One of the packages that your example is using generates errors when using it in R Markdown to generate Word or HTML output but works fine when creating PDF.One of the neat tools available via a variety of packages in R is the creation of beautiful tables using data frames stored in R. Some LaTeX packages work in all the various output formats for R Markdown and some don't. Did it create the file with the table that you expected? On my system it did. Now click the dropdown next to KNIT at the top of the window and choose Knit to PDF. Strictly speaking the hyphens before the \usepackage lines are not necessary. Third, paste Yarnabrina's code in to your new R Markdown document. Under File, you chose New file, and then R Markdown document? Try that now to start a new file. A normal R code file is created with an R extension. Second, are you entering your code in an R Markdown document? An R Markdown document is created with an RMD extension. In RStudio, go to your packages list, and check to make sure R Markdown is there. No offense meant by these questions:įirst, do you have the R Markdown package installed in your R environment? I assume since you are posting on the RStudio community forum, you do. I don't want to assume anything, but I like to verify some things that may be overlooked when troubleshooting.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |