code mnemonics

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

Roxygen skeleton

To add the roxygen2 skeleton to document a function:




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


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

# melt
melted1 <- mini_iris %>% melt(id.vars = "Species", = 'dimension','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


About moisesexpositoalonso

I am an enthusiastic young researcher. Born in 1990 and raised in Alicante, a coastal town in south-east Spain. With background in experimental ecology as an undergraduate (Sep2008-Jul2013) and population & quantitative genetics as masters student (Sep2013-Sep2014). Recently I started my PhD project (Oct2014-Sep2018) that deals with measuring evolutionary rates employing 1001 genomes of Arabidopsis and, particularly, understand climatic adaptation.
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: Logo

You are commenting using your 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