I updated my R version today and now I get an error with the lm()
function.
Now running on R version 4.0.3 (2020-10-10)
This is my data structure saved in df:
(if picture isn't loading, it's a dataframe with 2 columns: 'Date' and 'Value'. (dates are saved as date with as.Date() function)
I want to know the slope of the linear regression line, so I use the following function:
trend <- lm(formula = Date~Value, data=df)
It would normally return me the intercept and slope of the trend-line, but after the update of my R version, I get the following error:
Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : NA/NaN/Inf in 'y'
There are no NA values in my dataframe and I've not found how to fix this error. Does someone have a suggestion how to fix it or another way to get to know the slope of the trendline. I think it's because I use a date variable, because the function doesn't return an error if I use 2 numeric variables.
Thanks in advance for your time and help!
lm(value~Date, df)
There is no way date can be a response variable – Onyambu