This walkthrough is distributed under a Creative Commons Attribution 4.0 International (CC BY 4.0) License.
In order to use your data in R, you must import it and turn it into an R object. There are many ways to get data into R.
data.frame()and specify your variables.
rAltmetric, or World Bank’s World Development Indicators with
R has some base functions for reading a local data file into your R session–namely
read.csv(), but these have some idiosyncrasies that were improved upon in the
readr package, which is installed and loaded with
tidyverse. You can either load
tidyverse, which will automatically load
readr, or you can load
library(tidyverse) # or library(readr)
For this session, we will be reading a CSV from a web connection rather than saving the data to our computer and loading it into R. However, to do that, see the below section on Loading data from a local file.
To get our sample data into our R session, we will use the
read_csv() function and connect to a CSV saved on my GitHub using the
books_url <- url("https://raw.githubusercontent.com/ciakovx/ciakovx.github.io/master/data/books.csv") books <- readr::read_csv(books_url)
Rows: 5991 Columns: 12
── Column specification ──────────────────────────────────────────────────────── Delimiter: "," chr (11): CALL...BIBLIO., X245.ab, X245.c, LOCATION, LOUTDATE, SUBJECT, ISN,... dbl (1): TOT.CHKOUT
ℹ Use `spec()` to retrieve the full column specification for this data. ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.