I am fairly new to R, so I'm sorry if this is an obvious or basic question. I am trying to create a scatterplot of salinity over the course of one year. I executed this code line by line, but when I run ggplot, the only thing that appears in the Plots pane is a grey rectangle where the plot would usually be. I am currently using the latest update of RStudio.
I have already restarted RStudio and used dev.off(). I'm not sure what's going on.
'''
##Reset R's brain
rm(list=ls())
#set working directory
setwd("C:/Users/jelli/OneDrive/Documents/Rprojects/Thesis")
getwd()
#----------------------------------------------------------------------## #set up data
A screenshot isn't very useful, try to give us a better dataset following this isntruction:
Second: The dataset comes outside the aes() and you don't have to use the dollar-notation but can call the columns directly, also you need to define a x and y value for geom_point()
p <- ggplot(thesisdate,
aes(x = date , # (???)
y = salinity, color=stream_location) +
geom_point() +
facet_grid(rows = vars(water_system), cols = vars(session),
scales = "free") +
theme_classic())
did you add the correct column that should be plotted on x?
also I missed another error in your example, one closing parenthesis is at the wrong position.
try this:
p <- ggplot(thesisdate,
aes(x = date , # ???
y = salinity, color=stream_location)) +
geom_point() +
facet_grid(rows = vars(water_system), cols = vars(session),
scales = "free") +
theme_classic()
if this doesn't work, try without the facet_grid() first.