0

How can I read data from following URL in R https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data I tried

X <- read.csv(url("https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data"))

But it is not working.

lmo
  • 37,904
  • 9
  • 56
  • 69

1 Answers1

2

You don't need the url in there. Also, the file has no header, so say header = FALSE.

X <- read.csv("https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data",
              header = FALSE)
Tyler Byers
  • 131
  • 5
  • Getting following error: Error in file(file, "rt") : for https:// URLs use setInternet2(TRUE) – Ranjeet Singh Rawat May 26 '16 at 19:43
  • http://stackoverflow.com/questions/12647207/reading-url-in-r-and-rstudio makes it sound like your internet settings are incorrect. perhaps run `setInternet2(TRUE)` and then re-try – Tyler Byers May 26 '16 at 19:48
  • Tried. >setInternet2(TRUE) > X <- read.csv("https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data", header = FALSE) Error in file(file, "rt") : for https:// URLs use setInternet2(TRUE) Still not working. Same is the case on RGui – Ranjeet Singh Rawat May 26 '16 at 19:58
  • Try the suggestions in this link: http://stackoverflow.com/questions/23028760/download-a-file-from-https-using-download-file , like installing rcurl, or try just downloading the file. It sounds like an internet connectivity problem, which is tough for us to solve. Google for your specific error and see if you can solve the internet problem. – Tyler Byers May 26 '16 at 20:05