Secure importing
In the previous exercises, you have been working with URLs that all start with http://
. There is, however, a safer alternative to HTTP, namely HTTPS, which stands for HyperText Transfer Protocol Secure. Just remember this: HTTPS is relatively safe, HTTP is not.
Luckily for us, you can use the standard importing functions with https://
connections since R version 3.2.2.
This exercise is part of the course
Intermediate Importing Data in R
Exercise instructions
- Take a look at the URL in
url_csv
. It uses a secure connection,https://
. - Use
read.csv()
to import the file aturl_csv
. The.csv
file it is referring to contains column names in the first row. Call itpools1
. - Load the
readr
package. It's already installed on DataCamp's servers. - Use
read_csv()
to read in the same.csv
file inurl_csv
. Call itpools2
. - Print out the structure of
pools1
andpools2
. Looks like the importing went equally well as with a normalhttp
connection!
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# 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