开始使用免费开始使用

安全导入

在前面的练习中,您一直使用以 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
  • 打印 pools1pools2 的结构。看起来导入效果和普通的 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

编辑并运行代码