How would you fit a linear model over a scatter-plot?



How would you fit a linear model over a scatter-plot?..

Answer / Omveer Singh

"To fit a linear model over a scatter plot in R, use the lm() function. This function calculates the coefficients of the best fitting line.nnExample:n```Rnx <- c(1, 2, 3, 4, 5)ny <- c(2, 4, 6, 8, 10)nlm_fit <- lm(y ~ x)nsummary(lm_fit)n```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More R Programming Interview Questions

What do you mean by data visualization in R?

1 Answers  


Explain how you can create a table in r without external file?

1 Answers  


What is attribute function in r?

1 Answers  


Give some examples of the functions in stringr.

1 Answers  


How would you join multiple strings together?

1 Answers  


What is data structure in r?

1 Answers  


Write the r programming code for an array of words so that the output is displayed in decreasing frequency order?

1 Answers  


Why we need data visualization in R?

1 Answers  


Write the syntax to set the path for current working directory in r environment?

1 Answers  


How to use R from python?

1 Answers  


Given a vector of numbers, how would you turn the values into scientific notation?

0 Answers  


Describe substr() in r string manipulation?

1 Answers  


Categories