I would like to add a label for each Year [2008-2017] for mean of Distance_m (Distance in meters) vs mean of RAI_CS (Relative Abundance Indices per Camera Station). I used plot
and ggplot
but have had no success.
I tried this code using plot
.
plot(tapply(MyData$RAI_CS, MyData$Year, mean)~tapply(MyData$Distance_m, MyData$Year, mean), MyData)
I cannot get the label=Year
to work. I come close with this code but cannot get the labels for each year to show, only data points of means, unhelpful as I don't know which year is which.
I tried this code in ggplot
.
ggplot(MyData, aes(x=mean(MyData$Disctance_m), y=mean(MyData$RAI_CS), label=MyData$Year))+ geom_point()
I get this warning message for ggplot
Warning messages:
1: In mean.default(MyData$Disctance_m) :
argument is not numeric or logical: returning NA
2: In mean.default(MyData$Disctance_m) :
argument is not numeric or logical: returning NA
3: Removed 2938 rows containing missing values (geom_point).
However, my data is numeric despite this warning. I want the mean distance vs mean RAI and one data point for each year to be labelled with the year on the plot.
dput
? Avoid$
in thetidyverse
and also check thatDistance*
orRAI*
is indeed numeric. – NelsonGon