library(tidyverse)
<- read_csv("flint.csv") flint
File paths and reading in data
Hopefully you have followed the advice here and organized your RStudio
files into folders like this:
And so, for example, when you go inside your Lecture 2 folder, it looks like this:
This is great for organization, but it causes a small problem. A command like this may not work:
Why not? Because the file flint.csv
is inside one of your handy dandy folders, but you have not told read_csv
which folder, and so it cannot find it. To fix this, change the code to this:
<- read_csv("~/lecture-2/flint.csv") flint
The string "~/lecture-2/flint.csv"
is called a file path and it tells the function read_csv
the path of folders it has to search down in order to find the file flint.csv
. If you have chosen to give your folders slightly different names like Lecture 2
or Lecture-2
or lecture 2
or john-sucks
, that’s fine. Just make sure you make the appropriate change when you run the command. So flint <- read_csv("~/Lecture 2/flint.csv")
or flint <- read_csv("~/john-sucks/flint.csv")
, etc.