R Markdown cannot open file - permission denied

Not so much a question but hopefully this helps someone:

When I was trying to use knit, I kept getting an error saying permission denied/cannot open 'such and such' file and I could not find help anywhere. I read forums about updating packages, running R studio as an administrator, installing different packages, even some people just straight up saying it just happens for no reason sometimes. I am very junior in my experience so bear with me, but this is what I was observing:

If I start working on a project and create new files within the working directory that I'm going to be reading in files from, or start moving files around, I get the permission/cannot open error when I go to knit.

As an example:
I create a project and set the directory to "documents\project\data_files" and this is where I am reading in .csv files. I cannot then go and create a file within data_files called images and put map images in there. Even if I specify that I only want to read in the csv files and the working directory is set to data_files, it gets to my other file called images and throws and error. When I move everything out of data_files and only keep the csv files, no issues. Move the images file back in, boom, error.

So, I either set my project directory to one level above my data, then set my working directory in a code chunk to use temporarily for my data, or I set my root directory where the data is for the whole project, and don't put anything else in that folder.

I just saw a bunch of people having this permission issue and not getting it resolved so when I finally fixed mine I hoped I could help someone else. If anyone has any idea or knows why it occurs and wants to share that would be great, this is just what I was noticing.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.