With R Markdown I can write a document that will read in the data and do visualizations and other analysis. The dataset that we’re sharing on GoogleDrive is growing still, usually every month but sometimes as often as every week it’ll update. I’m working on a big project right now with a team of other researchers. Regardless of what format you use, they’re automatically formatted and the code, plots, and other output are automatically included, so your methods for producing some plot or analysis are immediately transparent. In Word, everything comes with preset formatting, but if you’ve used styles in Word it’s easy enough to change those. Saving the file as a PDFs is very similar to using LaTeX, if that’s the way you want to go. If you have a way to host them, the HTML files can easily be put online for others to see. When you work with R Markdown, you’re working in RStudio, but you then “knit” the files up and they produce HTML files, PDFs, or Microsoft Word files. In fact, all of the handouts I’ve done for these workshops were written entirely in R Markdown. It also saves some headache later because I know exactly where to go if I need to change a plot or something.Īnother major application of R Markdown is to produce professional-looking documents like the one you’re reading right now. When that is done, the transition to paper or presentation is easier because I already have the draft done. This is essentially a cleaned up version of the “journal”-style format above, but instead of recording my thought process as I learn something, it’s more of an explanation to an unknown audience. I only keep the plots and statistical models I might want to include in a real presentation or publication. When I have a more or less finished idea, I often write a draft of a research paper in the form of an R Markdown file. In the end, I have a long document with lots of code, but I can clearly trace my thought process the whole time. I run code and then leave some commentary, including things I learned, mistakes, and what I want to try next. I turn this into a journal by explaing what I’m doing as I do it. With R Markdown, I can organize all this into one coherant file. These R scripts tend to be very long because I often create lots and lots of plots and when I go through the code I can never remember which one is the one I want and waste a lot of time executing code just to find the plot I want. I create lots of plots and run lots of statistical models trying to get a feel for what I can find in my data. When I’m starting a new project, I do a lot of exploratory analysis. Let me give you several examples of things I do in R Markdown. The benefit of this is that you can type all the prose you want and then put some relevant block of R code and all the output will be right there. Essentially, it’s a way to combine notes and an R script in one file. R Markdown is a good solution to this problem. But even then, there’s often a disconnect between what’s in my notes and what is in my R script. For many of my projects, I have an accompanying file where keep all my notes, kind of like a journal of what I did that day. You forget why do did what you did and what things you learned from it. You might add some structure to the script using headers, and you can add comments to explain what code does, but after a while it can get unwieldy because there’s no narrative in your script. But sometimes if you’re working on a particular project you might end up with one very long script. To achieve this, use bothĬol.names and escape = FALSE.So far, most of what you’ve done in R has been with R scripts, which is perfectly fine. I was also interested in implementing column names with specific lineīreaks, which is a bit more complicated. Using LaTeX color specification from the xcolor package - this specifies a mix of 15% gray Stripe_color = "gray!15" species the stripe color Implements table striping with repeated headers for tables that span Latex_options = c("striped", "repeat_header") Position = "left" places table on left hand side of Linesep = "" prevents default behavior of extraĪdditional styling options are specified with Longtable = TRUE handles tables that span multiple Other arguments, and are described in moreĭetail in the help file of kableExtra::kbl().īooktabs = TRUE is generally recommended for Many of knitr::kable() arugments are passed as Here are options I used to create a basic table with default columnįigure 3: Raw data table PDF output with default column Route through Ĭreates a page break for each new numbered top level section. You and me both, Charlie! This is tricky. Require numerous external packages and plug-ins in order to output the So far every package I have found seems to Library ( tidyverse ) library ( kableExtra ) library ( gtsummary ) library ( palmerpenguins ) BackgroundĬan anyone point me to a good R package that can create tables thatĪre easily outputted in PDF.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |