Questions tagged [setwd]
41 questions
1
vote
1 answer
How to set path in R in windows operating system using r'path\to\directory'?
In windows operating system (OS), for python, I can use os.chdir(r"path\to\directory\").
Is there any way that I can set the path in R also in similar way?.
One of the way known to me is setwd(readClipboard()). (Taking path in clipboard,…
user2110417
1
vote
1 answer
In R, how to change working directory more easily?
In how to change working directory more easily?
Currently, if we use 'setwd',we have to add many '\', sometimes it's boring
Is there any easier way for this ? (Just like Python can add 'r' )
setwd('C:\Users\Administrator\Desktop\myfolder') # can't…

anderwyang
- 1,801
- 4
- 18
1
vote
1 answer
loop through batch read folders in setwd(), format dfs & write.csv() to different folder R
I have folders with 4 .csv files in each folder. Currently I am batch reading the .csv files in the folder:
setwd("/Users/Drive/MS/Ma/Ec/Effort_variation_Ec/MES1/")
ecosmpr <-
list.files(pattern = "*.csv") %>%
…

vermicellion
- 338
- 2
- 14
1
vote
2 answers
Go backward by N levels using setwd() in R
is there a way to go back in the directory using the R function setwd() by different levels?
for e.g.
> getwd()
/home/folder1/folder2/
I want to arrive in home in just one shot without typing setwd("../.."). It is very tedious to write n times…

Will
- 1,619
- 5
- 23
1
vote
0 answers
Why can't I change the working directory in RStudio?
I got some example codes from a course that start with
install.packages('maps')
install.packages('geosphere')
library(maps)
library(geosphere)
setwd("C:\\mydata")
...
Everything was fine until the command of setting working directory. Because I…

Paw in Data
- 1,262
- 2
- 14
- 32
1
vote
1 answer
Setting working directory R error u2069 cannot change working directory
Whenever I try to set the working directory I get an error message that says
Error in setwd("/Users/myname/Wedding\u2069") :
cannot change working directory
Specifically, the directory path is followed by "u2069"
I am working from a Mac. Any…

Danny
- 554
- 1
- 6
- 17
1
vote
0 answers
R package Installation failed: cannot change working directory
I get the following error message when trying to install package "rChart" in R:
**Installation failed: cannot change working directory**
Somebody advised me to install "Rcpp" before "rChart". So I did so.
However, it is still same before.
>…

Hokun Jeon
- 11
- 2
1
vote
1 answer
Path assignment to setwd() is delayed in for/foreach loop
The objective is to change within a for loop the current working directory and do some other stuff in it,.e.g. searching for files. The paths are stored in generic variables.
The R code I am running for this is the following:
require("foreach")
#…

rienix
- 711
- 1
- 6
- 12
1
vote
2 answers
Convenient directory handling in R
Since I'm working with many subdirectories, I find setwd() pretty inconvient, as it demands from me to remember what are the current and previous location and change them back every time I perform different analysis. Things get more complicated when…

mjktfw
- 840
- 6
- 14
0
votes
0 answers
Set a parent working directory then calling on subfolders R
Basic question sorry and probably already answered but having trouble searching for a solution.
I want to work on some data file:
C:/Users/userg/desktop/R/harv/trial1/short/data/file_name.csv
So in global settings I set my default working directory…

Gilrob
- 93
- 7
0
votes
0 answers
I cannot set/change my working directory directly in my R code. Instead, I have to manually set it in the file browser tab
For some reason, I am unable to set or change my working directory in my R-code itself. I'll include a line such as:
setwd("~/Documents/BeaverProject/HOBOData/Beav")
But it will be followed with an error:
Error in…

jaynesw
- 43
- 7
0
votes
1 answer
Changing WD in RMarkdown
My R Markdown script was running well until I had to access documents from another WD than my RMarkdown-file. I tried to change the WD. But it doesn't take it.
I might access documents from different folder during my R Markdown Document. How can I…

Nadiine El Nino
- 339
- 1
- 6
0
votes
2 answers
Set wd in RStudio
I am creating a series of r scripts that will be used by multiple people, meaning that the working directory of files used and stored will differ. There are two folders, one for the R code, called "rcode," and another to store the generated outputs,…

Vianey Rueda
- 35
- 4
0
votes
2 answers
Is there a way to change all the directory path for all R files?
I recently got a new computer and moved all my work files over to it. The main issue is that the file structure is slightly different than from my previous computer. Therefore, for my R code to work correctly, I'd need to change the path in setwd()…

dkro23
- 15
- 4
0
votes
1 answer
R setwd() "Error while opening file - The system cannot find the file specified"
I have a R script that should change the working directory using setwd().
My code:
setwd(file.path(work_dir, database_dir, study))
I can pause my script just before this line is supposed to execute (using browser()) enter the code into the console…

melmo
- 757
- 3
- 15