Having trouble importing datasets to my program. Beginner programmer here, with little experience in the field. I've tried importing the datasets manually using file.choose() function and also setting my working directory to my specific data function, but keep getting the same error. I've also downloaded tidyverse and readr prior to running the program so that doesn't seem to be the problem either.
My console just ends up saying:
Error: 'data/StateData.csv' does not exist in current working directory
And
Error in import("data/StateData.xlsx") : No such file
likely means that StateData.csv is in a different directory than expected. The recommended way to simplify locating files is using the {here} package. Install with
install.packages("here")
First look at the files pane in RStudio (if you're not using RStudio, come back for further direction)
to confirm that you have a data directory in your current working directory. Then click into it to confirm that you have StateData.csv saved there. Then
suppressPackageStartupMessages({
library(here)
library(readr)
})
dat <- read_csv(here("data/StateData.csv"))
It exists, as I can import the data manually from the file tab (on a Mac) but for some reason the data itself is not able to be read through the commands:
(df <- read.csv("data/StateData.csv"))
Attached below is a screenshot of what my problem looks like.
There's a clue in the first error message . There's a repeated data/data/ that implies your earlier code set things up so that your later code should omit the data/ before the csv name.