Publications by January

Using external data from within another package

02.03.2017

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: someFunc <- function() { data(pckgdata) foo <- pckgdata$whatever } This will result in an error: someFunc: no visible binding for global variable ‘pckgdata’ someFunc : <anonymous>: no visible bin...

637 sym R (409 sym/3 pcs) 4 img

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

15.03.2017

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 co-authors), looking no different than any ot...

3078 sym R (2175 sym/6 pcs) 12 img

Custom comparison function for sorting data in R

11.04.2017

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 example v <- list(a=c(2,1), b=c(1,3),...

3296 sym R (1155 sym/4 pcs) 6 img

rmd syntax highlighting in vim

19.09.2019

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. Related To leave a comment for the author, please follow the link ...

679 sym

Colorful tables in a terminal

20.07.2020

It all started when I wanted to have significant p-values shown on the terminal colored in red. The R terminal is capable of showing colors, simple formatting (like italics or bold) and Unicode characters, thanks to the actual terminal that does the job of displaying R output – whether it is the console of rstudio or a terminal window. You can ...

1828 sym R (3592 sym/3 pcs)