# R tips

Here I present some R tips and tricks I have learned from various resources over the years.

• For math styles in R plots. Thanks to @RLangTip

• Converting a matrix of characters into numeric

• Running the equivalent of knitHTML in RStudio on the command line. Note you must install pandoc first

• Passing command line arguments using rmarkdown::render(). Thanks to sjackman

source.Rmd

command line

source.Rmd

command line

be careful of the single quotes and double quotes: it matters!

• Testing for the presence of elements in one vector in another, i.e., the opposite of %in%

• How the bs function works for B-splines in R by Samiran Sinha

• Find records which occur in table 1 but not in table 2 using anti_join in dplyr. Thanks to ZevRoss

• Rendering .Rmd posts for site built with Jekyll using the servr package. In your website directory create a folder called _knitr and place the build.R script in there. Place the .Rmd file which contains the contents of your post in the _source directory of your website folder. Then from the root folder of your website run the following command:

If you get the following error:

Try passing the full path of the executable jekyll to the servr::jekyll() function (which can be found via which jekyll in the terminal) as noted here. For example, on my laptop I ran the following command from the root directory of my website:

• Find out which pandoc rmarkdown::render is using:

To set the pandoc that you want it to use, enter the following in your .Renviron file (which should be in your \$HOME directory):