RStudio-Github cheat sheet

We have recently started to work with Github in our research group and I would never go back. It is a great way to collaborate on code, keep track of changes while coding and also supervising your students coding during their thesis.

Getting RStudio and Github talking can be a bit tricky. And I have put together a some instructions how to make the connection. There are different options, wether you already are on Github and want to connect your repository to a new RStudio project or the other way round, pushing an existing RStudio project on Github.

Here is the Github – R studio Cheat Sheet.

 

RMarkdown presentation – title page picture

Creating presentations with RMarkdown in R is a useful alternative to using Power Point. It is very useful for code loaded presentations. But many people produce the results (figures) they present in R. And whenever something is changed in the data or code each figure has to be remade, save again and exchanged in the presentation. RMarkdown will do all that automatically.

But let’s start at the first page. Most presentations (that I have seen) have a picture on the title page, because pictures say more than words. So how do you put a picture on your RMarkdown presentation?

It took me a while to figure out, but it’s quiet easy. I assume you know how to get started with your presentation. Otherwise check out this link.

The first thing you need to fix are the first couple of lines in your RMarkdown file. After output you write: ioslides_presentation: css: styles.css

Bildschirmfoto 2016-08-25 um 21.10.17

Make sure the spacing is right! This will tell your RMardown to look for a css file.

The next step is to create a css file. Where you then can define all sorts of things, for example to put a picture on your title page.

  • open a new R Script
  • type the following code in it, including the url and name of the picture you want in the presentation.

Bildschirmfoto 2016-08-25 um 21.11.24

  • save it as style.css (make sure that it has .css as ending and nothing else)

R Studio keyboard shortcuts

When you code a lot in R it is nice to work with the keyboard. There are some commands and code you will repeat again and again and it is useful to know that there are shortcuts for certain code and commands. R studio has made a whole list of shortcuts: rstudio-IDE-cheatsheet. Here a small selection of what I have found useful:

Mac Windows
Move cursor to start of line Cmd+< home
Move cursor to end of line Cmd+> end
Change working directory Ctrl+Shift+H Ctrl+Shift+H
Select to line start/end Cmd+Shift+</> Ctrl+Shift+</>
Insert <- Option+- Alt+-
Insert %>% Cmd+Shift+M Ctrl+Shift+M
Copy line up/down Cmd+Option+▴▾ Shift+Alt+▴▾

 

Data wrangling with dplyr and tidyr

I’ve been introduced to two R packages lately and they have made my life so much easier. I am talking about dplyr and tidyr. They are great for manipulating data, meaning switching from wide to long data sets, summarize and group data. And they can easily be combined with plotting functions, such as ggplot.

The reason they are so useful is: more efficient coding, the syntax is easy to remember and easy to read. I will not explain each functions here, because there are already many good tutorials on the web. Here is a nice cheatsheet for starters and some more links.

Thank you Richard for introducing me to tidyr and dplyr!

Bildschirmfoto 2016-07-25 um 23.13.54

 

Thank you bryophyters

I’ve been cutting grasses and picking bryophytes for a whole day. Why the hell would anyone do that?

We have started a new project called FunCaB which tries to disentangle the roles of different plant functional groups, such as grasses, herbs and mosses. For this, we set up sites in boreal and alpine grasslands where we are removing these functional groups. And this means sitting for hours in front of a plot and cutting grasses or picking bryophytes. We will then measure how species composition is affected and how carbon dynamics changes when removing certain functional groups.

This one day in the field was nice, but also thought me how tough this task is. It is tedious work and we need a lot of helping hands to fulfill the task. So, thanks a lot to Linn and the students helping to get this work done!

FunCaBplots

The pictures show a plot before and after removing the herbs.