Session - import csv
There are packages to import all types of data and RStudio has wizards for just a few of the possibilities.
We are going to first import a csv using the wizard but also get the code to copy to scripts for reproducibility.
We will use the “Import Dataset” button (but you can also click on the file itself):
The base R doesn’t use any packages but imports a data frame
in R whereas {readr} is built on the base R and creates a neater tibble
tibble
is synonymous with data frame
but acts differently
A tibble… is a modern reimagining of the data.frame…
Tibbles are data.frames that are lazy and surly: they do less (i.e. they don’t change variable names or types, and don’t do partial matching) and complain more (e.g. when a variable does not exist).
This forces you to confront problems earlier, typically leading to cleaner, more expressive code.
https://tibble.tidyverse.org/)
Locate the file capacity_ae.csv
When the file is located {readr} is used automatically and the data preview populates
Whilst it’s possible just to select import, RStudio gives you the option to copy the code:
In the editor, once copied from the wizard or shared in a script: