Get startedGet started for free

Reading a European .csv

In most of Europe, commas (rather than periods) are used as decimal points. This creates an issue for comma-separated value files: since commas can no longer be used to separate values, semicolons are used instead.

For this reason, readr provides read_csv2(), which looks for ; to indicate column breaks and , to indicate decimal points. Other than that, it behaves just like read_csv().

In this exercise, you'll see what happens when you incorrectly use read_csv() on datasets that contain values separated by semicolons. You'll import a dataset that contains information on the girth, height, and volume for Black Cherry Trees.

This exercise is part of the course

Reading Data into R with readr

View Course

Exercise instructions

The readr package and the trees.csv file are loaded in your workspace.

  • Correctly import trees.csv with the read_csv2() function and store the result as trees.
  • View the dimensions of trees using the dim() function and print the first six rows of trees to the console.
  • Now incorrectly import the data with read_csv() and store the result as trees_wrong.
  • View the dimensions of trees_wrong using the dim() function and print the first six rows of trees_wrong to the console.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Import data with read_csv2(): trees


# View dimensions and head of trees



# Import data with read_csv(): trees_wrong


# View dimensions and head of trees_wrong

Edit and Run Code