TDM 10100: Project 4 Question 4 examples
Example 1
R provides a whole universe of functions called Tidyverse:
The Tidyverse was first envisioned by Hadley Wickham, and has now been broadly adopted at Posit (formerly called RStudio).
We can read data into a data frame, called a tibble in Tidyverse using read_csv from the tideverse library, for example, as follows:
library(tidyverse)
and then notice that we use read_csv instead of read.csv:
myDF = read_csv("/anvil/projects/tdm/data/icecream/combined/reviews.csv")
Do not worry about the pink-colored output after this runs.
We can check that we read it in properly:
head(myDF)
and we can even summarize a column to be sure:
table(myDF$brand)
Example 2
After we have already imported the tidyverse library, we do not need to re-import it. We can just read in more data frames as tibbles, e.g., like this:
myDF = read_csv("/anvil/projects/tdm/data/flights/subset/airports.csv")
Now we can check that we read it in properly:
head(myDF)
and we can even check which states have the most airports:
tail(sort(table(myDF$state)))