I am sorting data into bins and averaging, see this solution.
I am using the exact same solution as in the above link but fixing my data to a scatter plot instead. The code which is causing me difficulty is :
myData.class <- cut(df$xaxis, seq(0,30,length=60), include.lowest=TRUE)
mean.yaxis <- tapply(df$yaxis, myData.class, mean)
lines(mean.yaxis ~ seq(0, 30, length=60))
The call to lines is producing an error :
Error in model.frame.default(formula = mean.yaxis ~ seq(0, 30, length = 60), :
variable lengths differ (found for 'seq(0, 30, length = 60)')
A call to str(mean.yaxis) produces :
num [1:59(1d)] 0 0 0 0.349 4.652 ...
- attr(*, "dimnames")=List of 1
..$ : chr [1:59] "[0,0.508]" "(0.508,1.02]" "(1.02,1.53]" "(1.53,2.03]" ...
How can I access to correct data in my call to the function lines(...) ?