AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Rmarkdown echo12/28/2022 ![]() ![]() How do we call it from the main document (parent) and how to we give it the species variable if we cannot give it parameters? Knitr child document Ggplot(aes(x = bill_length_mm, y = bill_depth_mm)) + This document will not have any other yaml than the type of output is should contain. I’ll call it species-child.Rmd, in this case, choose the “Create empty document” in the RStudio UI. ![]() Making the child documentĬreate a new Rmarkdown file like before, and name it something meaningful. Since child documents cannot be parametrised this was in my opinion the smoothest solution. The child document will be another Rmd, that will depend on certain things existing in its enviroment to run. We can make a so-called “child”-document, and provide it with what it needed to create what we wanted. We could copy and paste the code, with filters to only grab the species we want.īut we’d have to do that three times, and if we wanted to change something, we’d have to change it in all three places. We want, one chapter per penguin species. SO we now have an overall plot and table for all the penguins.īut say I want to have one section for each of the three penguins species.Īnd lets forget about grouping data and making colours in the plots to easily see the species. You can read lots about pivoting on the tidyverse pages. We did quite a lot here, and I for once don’t intend on digging into the details of what I did. fns = list ( mean = mean, min = min, max = max, N = length ). Library ( tidyr ) penguins %>% pivot_longer ( ends_with ( "mm" ), names_to = "cols", values_to = "mm", values_drop_na = TRUE ) %>% group_by ( cols ) %>% summarise ( across ( mm. I deleted everything in the main document (we could have just created an empty one in the step before also). This is the document where we will call on other rmarkdown templates to be added. Now we have a main document to create from. Let’s make some files to test! Create the Rmdįirst off, we will make an Rmd file, by going to File -> New file -> Rmarkdown … in RStudio, then choose to create a PDF. In the end, I opted for a solution that looked really awesome, and I currently cannot find the tweet that pointed me in that direction (if anyone finds it, let me know so I can attribute properly!) We had some nice conversations and people offered awesome advice. I'd love to not copy+paste + edit all these sections, just input as sub-report- Athanasia Mowinckel October 11, 2021Īnd this was not at all a super easy thing to do, it turns out! I have q's following two basic logics, and thus two sets of text+chunk based on these. Rmd wishlist: a parametrized sub-section.Ī way to input whole sections (text and chunks) with some parameters. ![]() Ideally, I wanted a type of Rmarkdown parametrised report I could provide data, titles and small text snippets to to generate a whole set of descriptives and statistics for me for the various questions.Īs I often do, I went to the #Rstats twitter Gods for help. ![]() I know how to make Rmarkdown parametrised reports, and I kind of wanted something similar, but in a nested fashion. RMARKDOWN ECHO CODEI was doing a lot of copy and paste of code, with whole code chunks and text for each of the questions, then doing simple search and replace of data and strings. The survey has two basic type of questions, likert-scale questions and binary yes/no questions.įor each of these two types of questions, I’ve needed to generate a set of descriptive plots and tables, as well as run a particular set of statistical models. This has been really fun, but also a little tedious. I have recently been working on a set of analyses from a survey at work. ![]()
0 Comments
Read More
Leave a Reply. |