Zapata Zapata - 1 year ago 69
R Question

Error in load data in r software - rmarkdown knit

I am new to R programming, so, please bear with me. I want to run a multi linear regression and do prediction for my sport data.

summary (sports)
fit = lm(sport_score ~ sport_votes + sports_rating)

newdata = data.frame( sport_vote = 80, sport_rating = 7.7 , data = sports)

predict(fit, newdata, interval="predict")

I have used this code which works well and prints the outputs for me perfectly in the console. But, when I want to knit it it has an error of:

Error in load(sports.rdata) : object 'sports.rdata' not found calls: ... withcallinghandles -> withvisible - > eval -> eval -> load

42- 42-
Answer Source

Me: One of the reasons for never using attach is that the error messages become completely uninterpretable. In this case it's entirely a matter of speculation because the is no definiton of sports. Perhaps you intended to write load('sports.rdata')? – 42- 1 hour ago

You: It gives me the same error of : error in load(sports.rdata) .... – Zapata 59 mins ago

Me: You are not reading carefully. You would not have gotten that error message if you wrote what I wrote. You failed to notice the quotes. – 42- 57 mins ago

You: I removed the attach and used the load('sports.rdata') is that what you meant? – Zapata 53 mins ago

Me: Yes. If you remove the attach then you will need to use a data=sports argument in lm()

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download