Blog Archives

rmd syntax highlighting in vim

September 19, 2019
By

Quick and dirty Rmarkdown syntax highlighting for vim, when you don’t have time install bundles, plugins or dependencies: go to this github repository, download the file rmd.vim from the syntax/ directory and copy it to ~/.vim/syntax/. This should work in 99,99% of the cases.

Read more »

Custom comparison function for sorting data in R

April 11, 2017
By
Custom comparison function for sorting data in R

Many languages allow you to use a custom comparison function in sorting. R is not an exception, but it is not entirely straightforward – it requires you to define a new class and overload certain operators. Here is how to do it. Consider the following example. You have a certain number of paired values, for

Read more »

Adding figure labels (A, B, C, …) in the top left corner of the plotting region

March 15, 2017
By
Adding figure labels (A, B, C, …) in the top left corner of the plotting region

I decided to submit a manuscript using only R with knitr, pandoc and make. Actually, it went quite well. Certainly, revisions of manuscript with complex figures did not require much of manual work once the R code for the figures has been created. The manuscript ended up as a Word file (for the sake of

Read more »

Using external data from within another package

March 2, 2017
By
Using external data from within another package

If you make the error which I did, you will try to use the data (say, “pckgdata”) from another package (say, “pckg”) naively like this: This will result in an error: Here is the solution (thanks to the comments from stackexchange:

Read more »

R-devel in parallel to regular R installation

July 1, 2015
By
R-devel in parallel to regular R installation

Unfortunately, you need both: R-devel (development version of R) if you want to submit your packages to CRAN, and regular R for your research (you don’t want the unstable release for that). Fortunately, installing R-devel in parallel is less trouble than one might think. Say, we want to install R-devel into a directory called ~/R-devel/,

Read more »

Presentations in (R)markdown

June 24, 2015
By
Presentations in (R)markdown

There are many ways to turn a markdown or Rmarkdown document into a presentation. Way too many, and none of them is perfect. I made my first presentation with knitr / Rmarkdown for the tmod package. After trying various options in knitr, I decided on an approach in which the Rmarkdown document is oblivious of

Read more »

Kneat tricks

June 18, 2015
By
Kneat tricks

So I have finally switched to knitr for doing my vignettes. The result is satisfactory, but the process was not entirely painless. The command to run instead of “R CMD Sweave foo.Rnw” is Rscript -e 'rmarkdown::render("foo.rmd")' I think that the concept of writing a package which has the main purpose to generate documentation in literate

Read more »

pandoc, markdown and pander

April 23, 2015
By
pandoc, markdown and pander

Pandoc + markdown seem to be a great way of documenting my work. Markdown syntax is very simple and allows to add basic formatting and figures to an otherwise simple text document, without obfuscating the actual text. Then I simply compile the document using the pandoc command: There are some more tricks, of course, and

Read more »

Creating a graph with variable edge width in Rgraphviz

March 26, 2015
By
Creating a graph with variable edge width in Rgraphviz

This was waaaaay more complicated than necessary. Figuring it out took me almost a whole day. In essence, there is the graph package in R, which provides graph objects and methods, and there is the Rgraphviz package, which allows you to plot the graphs on the screen. They work well. Here the output: So far,

Read more »

Adding authentication to a shiny server

December 5, 2014
By
Adding authentication to a shiny server

Umph, that was a tough one. I spent ages figuring out how to do it correctly. I have a server running apache (on port 80) and shiny on port (say) 11111. Shiny has its own document root, and within this root, we have a shiny app, say, “example”. So to view this app you need

Read more »

Search R-bloggers

Sponsors

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)