Anil Kumar
Anil Kumar

Reputation: 31

Error is returned while using getURL() function in R language

i have started learning data science and new to R language, i am trying to read data from below HTTPS URL using getURL funtion and Rcurl pacakge.

while executing below code, receiving SSL protocal issue.

R Code

load the library Rcurl

library(RCurl)

specify the URL for the Iris data CSV

urlfile = 'https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data'

download the file

downloaded = getURL(urlfile, ssl.verifypeer=FALSE)

Error

Error in function (type, msg, asError = TRUE) : Unknown SSL protocol error in connection to archive.ics.uci.edu:443

can anyone help me with this answer?

Upvotes: 3

Views: 3551

Answers (1)

Katherine
Katherine

Reputation: 21

First see if you can read data from the URL with:

fileURL <- "https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data"
myfile <- readLines(fileURL)
head(myfile)

If you can read data from the URL, then the embedded double quotes in the data may be causing your problem.
Try read.csv with the quote parameter:

iris <- read.csv(fileURL, header = FALSE, sep = ",", quote = "\"'")
names(iris) <- c("sepal_length", "sepal_width", "petal_length", "petal_width", "class")
head(iris)

Upvotes: 2

Related Questions