S
Swetha Shetty

Posted on 19th April 2024|486 views

0
votes

Error In Lm Fit X Y Offset Offset Singular Ok Singular Ok Na Nan

How to resolve the error Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...)? I have the following code > str(alla) 'data.frame': 11 obs. of 4 variables:  $ demo : chr "498.300.775" "500.297.033" "502.090.235" "503.170.618" ...  $ tot : chr "4.846.423" "4.891.934" "4.901.358" "4.906.313" ...  $ besch: num 69.8 70.3 69 68.6 68.6 68.4 68.4 69.2 70.1 71.1 ...  $ usd : num 1.37 1.47 1.39 1.33 1.39 … But it is an error called  > abline(lm(alle$demo~alla$tot)$coef) Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) :    NA/NaN/Inf in 'y'
Answers
P
Anusha V

Posted on 19th April 2024

Try this 

alla$demo <- as.numeric(gsub("\\.", "", alla$demo))

alla$tot <- as.numeric(gsub("\\.", "", alla$tot))

Then test

FIT <- lm(alle$demo~alla$tot)

 

To see if you get any errors. Then

abline(reg = FIT)

 

Write your answer

STILL GOT QUERIES?

Get a Live FREE Demo
  • Explore the trending and niche courses and learning maps
  • Learn about tuition fee, payment plans, and scholarships
  • Get access to webinars and self-paced learning videos