R Markdown Tips
Posted on Jun 09, 2016 in Programming
Things under legendu.net/outdated are outdated technologies that the author does not plan to update any more. Please look for better alternatives.
** Things under legendu.net/outdated are outdated technologies that the author does not plan to update any more. Please look for better alternatives. **
-
The
rmarkdownpackage is preferred to themarkdownpackage. There is also a small bug with themarkdownpackage.markdown::markdownToHTMLdoes not render markdown title of the format##Titlecorrect. A space is required after#formarkdownToHTMLto work. However,rmarkdown::renderworks well on both situations. -
There are several ways to pass values between the R workspace and R Markdown. One way is to use global variables (from the R workspace) in R Markdown directly. However, you have to tell R Markdown the right working environment using the option
envir = 0. Without this, R Markdown uses the current working environment which might not be the global working environment (e.g., whenknitis called inside a function). Sometimes, it is more convenient to substitute patterns in R Markdown with required values directly. Make sure to use unique patterns if you do it in this. For example, if you want to pass a variablesiteby substituting into R Markdown, a good way is to replace pattern${site}(instead of plainsite) with the value of the variablesite. -
Avoid doing complicated calculations in RMakrdown. Separted the code for calculation, etc., and use rmakrdown for reporting purpose mostly ...,
-
plotly(for graphics) andDT(for tables) are great visualization tools to use with R Markdown.