Error in xy.coords(x, y, setLab = FALSE) : 'x' and 'y' lengths differ

Hi, I'm new to R and am trying to fit a line of best fit to a data set that loosely follows that of an exponential decay function. I keep getting the error that x and y lengths differ and am not sure how to fix this. Any help would be appreciated. This is the code I am entering.

plot(Velocity$d[Time>15], jitter(Velocity$FluctuationVariable[Time>15], 2),
main = "FLUCTUATION VERSUS WATER DEPTH AFTER SURGE",
xlab = "Water Depth (Metres)", ylab = "Fluctuation Variable (Metres/Second)")
exponential.model = lm(Velocity$FluctuationVariable[Time>15] ~ log(Velocity$d[Time>15]))
summary(exponential.model)
lines(smooth.spline(Velocity$d,predict(exponential.model)), col="orange")

I think you forgot about Time > 15

length(predict(exponential.model))
length(Velocity$d)
 
 table(Time>15)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.