Exercise: Read Data

Read in the data (a csv file) from https://goo.gl/dWrc9m to a data frame called gapminder (data is also in data/gapminder5.csv if you don’t have an internet connection). Do you need to make any adjustments to the defaults? Note: you can specify a url instead of a filename/file path when using read.csv.

Look at the type of each column in the data you read in.

View the observations for Belgium.

Exercise: Read Tab-delimited

Read in the tab-delimited file (states.txt) at https://goo.gl/AwnS4R (data is also at data/states.txt). What changes do you need to make to read in tab-delimited data? Are any other adjustments to the defaults warranted?

Change the column names to state, lat, and lon.

Does anything look strange to you about this data?

Exercise: Write a data file

You read in the state data above. Now write it to file as a CSV file, with sensible options.

Challenge Exercise: Reading Excel Files

Create an Excel file. Read it into Excel with the readxl package. How would you read in the second sheet?