简体   繁体   English

在 R 语言中使用 getURL() 函数时返回错误

[英]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.我已经开始学习数据科学和 R 语言的新手,我正在尝试使用 getURL 功能和 Rcurl pacakge 从 HTTPS URL 下方读取数据。

while executing below code, receiving SSL protocal issue.在执行以下代码时,收到SSL协议问题。

R Code代码

load the library Rcurl加载库 Rcurl

library(RCurl)库(RCurl)

specify the URL for the Iris data CSV指定虹膜数据 CSV 的 URL

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函数错误(类型、msg、asError = TRUE):连接到 archive.ics.uci.edu:443 时出现未知 SSL 协议错误

can anyone help me with this answer?谁能帮我回答这个问题?

First see if you can read data from the URL with:首先看看你是否可以从 URL 中读取数据:

fileURL <- " https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data "文件URL <-“ https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data
myfile <- readLines(fileURL) 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.如果您可以从 URL 读取数据,则数据中嵌入的双引号可能会导致您的问题。
Try read.csv with the quote parameter:尝试 read.csv 与 quote 参数:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM