Part 36 Filesystems and paths
Let’s first load the built-in gapminder dataset and the tidyverse:
library(gapminder)
library(tidyverse)
Next, let’s filter the data to only 2007 and only the Asia continent and save it to a new object.
<- gapminder |> filter(year == 2007, continent == "Asia")) (gap_asia_2007
We can write this to a comma-separated value (csv) file with the command:
write_csv(gap_asia_2007, "exported_file.csv")
But where did this file go? We should save the file in a sensible location. We need to practice controlling where R is running, where it looks for files, and where it writes out your files. To that end, let’s review the working directory and RStudio Projects.