安全导入
在前面的练习中,您一直使用以 http:// 开头的 URL。不过,还有一种更安全的替代方案:HTTPS,全称为 HyperText Transfer Protocol Secure。只需记住这一点:HTTPS 相对安全,HTTP 则不安全。
幸运的是,从 R 3.2.2 版本开始,您就可以将标准的导入函数用于 https:// 连接。
本练习是课程的一部分
R 数据导入进阶
练习说明
- 查看
url_csv中的 URL。它使用的是安全连接https://。 - 使用
read.csv()导入url_csv指向的文件。该.csv文件第一行包含列名。将结果命名为pools1。 - 加载
readr包。它已经安装在 DataCamp 的服务器上。 - 使用
read_csv()读取同一个url_csv中的.csv文件。将结果命名为pools2。 - 打印
pools1和pools2的结构。看起来导入效果和普通的http连接一样好!
交互式实操练习
通过完成这段示例代码来试试这个练习。
# https URL to the swimming_pools csv file.
url_csv <- "https://assets.datacamp.com/production/course_1478/datasets/swimming_pools.csv"
# Import the file using read.csv(): pools1
# Load the readr package
# Import the file using read_csv(): pools2
# Print the structure of pools1 and pools2