Introduction to R projects

It often makes sense to separate your projects. And since space is cheap you are probably creating separate folders on your computer. In RStudio you can create different projects that live in their own folder. When you start a different project the files of that project work independently from other projects. And the standard locations of your workspace and other things are also separated from the rest. In my case, for example, I have several projects and the last 10 or so are displayed in the dropdown menu: [Read More]

From spss to R, part 4

This is the second part of working with ggplot. We will combine the packages dplyr and ggplot to improve our workflow. When you make a visualisation you often experiment with different versions of your plot. Our workflow will be dynamic, in stead of saving every version of the plot you created, we will recreate the plot untill it looks the way you want it. In the previous lesson we worked with some build in datasets. [Read More]

Creating a package for your data set

Turning your dataset into a package is very useful for reproducable research. This tutorial is for you, even if you’ve never created a package in r. Why would you turn your dataset into a package? very easy to share easy to load (library(name) is easier then load("path/to/file") or data<-read.csv("path/to/file") etc.) documentation is part of the package and will never separate from data attributes of file remain nice and easy introduction to package building What do you need to do to create a dataset package: [Read More]

From spss to R, part 3

In this post we will start with a build-in dataset and some basic ggplot graphics. In the next post we will combine dplyr and ggplot to do awesome stuff with the Dutch University student counts from the previous lessons. We will work with the build-in dataset mtcars. There are many datasets in r library(help = "datasets") but in many examples online you will see the iris and mtcars examples. Find more information about the dataset with ? [Read More]

Version control with Git

Keeping track of versions You work on a project and would like to keep track of what you did. That is why keep old versions of your files. That way you can go back if you messed up beyond recognition. Usually that looks like this: Or you use dropbox or something like it: Other people use email. Emailing to themselves or to collaborators when they finished something. [Read More]

Tidying your data

Introduction To make analyses work we often need to change the way files look. Sometimes information is recorded in a way that was very efficient for input but not workable for your analyses. In other words, the data is messy and we need to make it tidy. Tidy data means 1: Each variable forms a column. Each observation forms a row. Each type of observational unit forms a table. [Read More]

From spss to R, part 2

Introduction In this lesson we will open a .sav file in Rstudio and manipulate the data.frame. We will select parts of the file and create some simple overviews. First time with R? No problem, see lesson 1 toc {:toc} Download a .sav (SPSS) file I downloaded the following dataset from DUO (Dienst uitvoering onderwijs): [Aantal wo ingeschrevenen (binnen domein ho)][3]. This dataset has a cc0 declaration, which means it is in the public domain and we can do anything we want with this file. [Read More]

From spss to R, part 1

Introduction This whole blog is devoted to R and clean coding in R. But what if you want to start with R? There are millions of websites devoted to learning R. just look at the number of hits on a certain search machine. Most of these hits start with the basics and slowly work your way up to more advanced examples. There is often one reason to start with R: you want to achieve something that doesn’t work in other programs. [Read More]

Portioning projects

Often we write programs to automate things. The programs range from simple to complex. But in essence, you always do the same thing: You are trying to solve a problem. A common pitfall, at least for me, is that you start out to big. What you need to do is start simple and small, and only if your simple thing works, increase the complexity. Separate parts of the program need to be separate functions. [Read More]