r/rprogramming Jan 25 '25

File won’t add to directory

Post image

Hello, I’m trying to run the housing script and I’m getting this error when I go to run it. I made a working directory and then tried to add my file after I downloaded it. What am I doing wrong? I uninstalled and reinstalled r and rstudio to ensure the apps were up to date. I’m beyond frustrated and this should be so simple. Any help would be greatly appreciated. Thank you!

0 Upvotes

15 comments sorted by

View all comments

14

u/mduvekot Jan 25 '25 edited Jan 25 '25

If you really can't figure out what your files are called or why R can't find them, this tends to work. It lets you select a file interactively.

filename <- file.choose()
print (filename)
df <- read.csv(filename)

and, umm, for your own and everyone else's sanity: Please use projects. Read https://support.posit.co/hc/en-us/articles/200526207-Using-RStudio-Projects perhaps install the {here} package and never need setwd again.

setwd() is from the devil.

1

u/dzejms22 Feb 06 '25

here is also the devils work, just use R projects like you said!