Building on @jkrideau's response a little bit, to get the plot in a single command using base R (plot and subset):
plot(x = subset(Allsites_data$Year, Allsites_data$Site == "Brownstone"),
y = subset(Allsites_data$Nitrate, Allsites_data$Site == "Brownstone"))
The kicker is this may not give you quite what you want depending on the data type of Year
in the data frame (which is one of the reasons a reproducible example is nice to have). If Year
is numeric, then you may see things like "2011.5" in the x-axis of a dot plot.
If, instead, Year
is a factor, you may get a y-axis that is more what you expected, and you will likely get a boxplot instead of a dot plot.
Depending on what you're looking for, specifically, you may need to do a little bit of light work on the data frame or do some additional formatting work within plot()
(or, potentially, consider switching over and using ggplot()
, but my sense is that you're not looking to dive into that world).
Good luck!