brittAnderson / Intro2Computing4Psychology

A guided introduction to computing tools useful for research in psychology - targeted to complete beginners
47 stars 159 forks source link

Plotting in R #46

Closed katevk closed 3 years ago

katevk commented 3 years ago

Hello, I am trying to do the interaction plot in R with ggplot2 but it keeps saying the degreedays cannot be found. Did anyone else have this problem? I have attached an image for reference.

degreedays

kaitlingaerlan commented 3 years ago

Hi Kate, I had the same issue and what worked for me was adding the argument “header=TRUE” to the read.csv line Also, I think you mean to write qplot(df) instead of ggplot(df)

brittAnderson commented 3 years ago

If you open up heating.txt in an editor (maybe emacs?) you will see that the first line is the labels for the column header. By adding the line header = true that @kaitlingaerlan mentions lets R take that into account when getting the data. Some other data sets may skip that line and just start with the data. Some files will have even more stuff above the data and you will have to skip multiple lines. read.csv also has an argument for that too.

katevk commented 3 years ago

That makes a lot more sense. Thank you for the help!