0

I am getting a very strange issue when using R-Markdown and when I press KNITR. Each time I run the script I get the error below.

Error in read.csv(url("https://www.nomisweb.co.uk/api/v01/dataset/NM_1_1.data.csv?geography=1249902593...1249909543&date=latestMINUS2-latest&sex=7&item=1&measures=20100")) : could not find function "read.csv"

This code does not feature in my script and exists in another document that I had created. I have changed the folder directory, cleared the environment. Yet this annoying error keeps appearing when pressing KNITR. I have created a new file, directory everything yet it keeps appearing.

I would be grateful for any pointers.

barbsan
  • 3,418
  • 11
  • 21
  • 28
MD1
  • 11
  • 2
  • Possible duplicate of [Error: could not find function ... in R](https://stackoverflow.com/questions/7027288/error-could-not-find-function-in-r) – barbsan Mar 07 '19 at 13:08
  • What do you mean "exists in another document that I had created"? Is this code you want to be running, or is this undesired code that is running for some unknown reason? I think if you want any real help, you need to provide a [mcve] of your rmarkdown file that reproduces that error. – divibisan Mar 07 '19 at 16:55

1 Answers1

0

Try to run read.csv from utils package as shown

utils::read.csv(url("https://www.nomisweb.co.uk/api/v01/dataset/NM_1_1.data.csv?geography=1249902593...1249909543&date=latestMINUS2-latest&sex=7&item=1&measures=20100"))

or

library(utils)
read.csv(url("https://www.nomisweb.co.uk/api/v01/dataset/NM_1_1.data.csv?geography=1249902593...1249909543&date=latestMINUS2-latest&sex=7&item=1&measures=20100"))

Lunalo John
  • 325
  • 3
  • 10
  • Hello Mr Lunalo so will running this code stop the line of code appearing in R Markdown? – MD1 Mar 07 '19 at 12:51
  • Yes, What is happening is that the standard packages in r might be loading after your r profile is is processed so you have to call the package again to access the function. – Lunalo John Mar 07 '19 at 13:00
  • Thank you very much sir, i am trying that right now. Many thanks. – MD1 Mar 07 '19 at 13:11
  • Hello Mr Lunalo, I have tried your suggestion by pasting in the above code in the RMarkdown script and i still get the same error. Error in read.csv(url("https://www.nomisweb.co.uk/api/v01/dataset/NM_1_1.data.csv?geography=1249902593...1249909543&date=latestMINUS2-latest&sex=7&item=1&measures=20100")) : could not find function "read.csv" – MD1 Mar 07 '19 at 14:44
  • As mentioned it seems to be referencing an old link to something in my RMarkdown. – MD1 Mar 07 '19 at 14:44
  • Hello thank you sir, but unfortunate this code didnt work. But thank you for your suggestion. Regards MD – MD1 Mar 07 '19 at 16:17