An error message has come up when i am trying to use the lm function
Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) :
NA/NaN/Inf in 'y'
In addition: Warning message:
In storage.mode(v) <- "double" : NAs introduced by coercion
This is my code:
rm(list=ls())
COVID19_DATA_3 <- read.csv("C:/Users/User.DESKTOP-IVGA5BC/Desktop/COVID19_DATA_3.csv", header=FALSE)
COVID19_DATA_3$V8=as.character(COVID19_DATA_3$V8)
COVID19_DATA_3$V11=as.character(COVID19_DATA_3$V11)
plot(COVID19_DATA_3$V11,COVID19_DATA_3$V8)
plot(COVID19_DATA_3$V11,COVID19_DATA_3$V8, ylim=c(0,2000))
plot(COVID19_DATA_3$V11,COVID19_DATA_3$V8, xlim=c(0,50),ylim=c(0,500))
fit <-lm(COVID19_DATA_3$V11~COVID19_DATA_3$V8)
plot(COVID19_DATA_3$V11,COVID19_DATA_3$V8)
abline(fit, col = "blue", lwd=1)
My data consists of column V8 and V11 and it consists of ONLY integers and NA values. Not sure if i use the wrong function 'as.character'. But i tried without using it and it turns out that the scatter plot gives a series of lines instead of dots.
This is a brief section of how my data look like. (V8 and V11 only has integer values and NA values)
Referred here from support.rstudio.com