code mnemonics

Compilation of useful programming tips that I sometimes need but always forget about.


Stag all removed files in git

git rm $(git ls-files –deleted)


Roxygen skeleton

To add the roxygen2 skeleton to document a function:

shift+ctrl+alt+r

shift+opt+cmd+r

source


 Correspondance between reshape2::melt and tidyr::gather, reshape::dcast and tidyr::spread

library(reshape2)
library(tidyr)
library(dplyr)

mini_iris <- iris[c(1, 51, 101), ]

# melt
melted1 <- mini_iris %>% melt(id.vars = "Species",value.name = 'dimension',variable.name='trait')
melted2 <- mini_iris %>% gather(key='trait', value='dimension', -Species)

# cast
melted1 %>% dcast(Species ~ trait, value.var = "dimension")
melted2 %>% spread(key='trait', value='dimension')

        

 


Insert or overwriting mode shortcut

Not really a command, but super annoying for a linux computer using a mac keyboard.

Shortcut: fn + return

Advertisements

About moisesexpositoalonso

PhD student working on Evolutionary Genomics under Prof. Detlef Weigel at the Max Planck Institute for Developmental Biology in Germany (Oct 2014 – 2018). My work revolves around climate change adaptation and evolutionary rates of the plant Arabidopsis thaliana.
This entry was posted in Sin categoría. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s