Importing data into R to start your analyses—it should be the easiest step. Unfortunately, this is almost never the case. Data come in all sorts of formats, ranging from CSV and text files and statistical software files to databases and HTML data. Knowing which approach to use is key to getting started with the actual analysis.
In this course, you will get started with learning how to read CSV and text files in R. You will then cover the readr and data.table packages to easily and efficiently import flat file data. After that you will learn how to read XLS files in R using readxl and gdata.
Lots of data comes in the form of flat files: simple tabular text files. Learn how to import all common formats of flat file data with base R functions.
Lots of data comes in the form of flat files: simple tabular text files. Learn how to import all common formats of flat file data with base R functions.
The utils package, which is automatically loaded in your R session on startup, can import CSV files with the read.csv() function.
In this exercise, you’ll be working with swimming_pools.csv; it contains data on swimming pools in Brisbane, Australia (Source: data.gov.au). The file contains the column names in the first row. It uses a comma to separate values within rows.
Type dir() in the console to list the files in your working directory. You’ll see that it contains swimming_pools.csv, so you can start straight away.
INSTRUCTIONS 100 XP Use read.csv() to import “swimming_pools.csv” as a data frame with the name pools. Print the structure of pools using str().
HINT Simply pass the path to the CSV file to read.csv(): read.csv(“swimming_pools.csv”). An example: str(df) will give you the structure of a data frame df.
https://www.dropbox.com/s/unbyqfspb95rsqm/swimming_pools.csv?dl=0