Getting your own data into R is not always easy. There are several useful recent packages that can help you import your csv, Excel, or SPSS file. Please do note that the functions will treat variables differently whether they are numeric or not (e.g., factors, categorical variables, string variables). A variable with zeros and ones to signify women and men will be seen as a continuous variable.
To read in a csv-file:
To read in an Excel-file:
To read in an SPSS-file:
Two ways to reduce frustration:
When you open an RStudio-project, and you put your data file in the same folder as the .Rproj file, you do not need to specify the path, but can simply write
You can also use
read_sav( file.choose() ), which opens up a window that lets you select your datafile with point-and-click.
The first method is a bit better because it is more ‘reproducible’.
For this workshop, we’ll use data that are provided in the ggplot-package, so we do not need to read in our data.