Get & Set Working Directory in R (3 Examples) | getwd & setwd Functions | Change File Path of Folder
HTML-код
- Опубликовано: 21 авг 2024
- How to identify and change working directories using the getwd and setwd functions in the R programming language. More details: statisticsglob...
R code of this video:
getwd() # Apply getwd function
setwd("C:/Users/Joach/Desktop/my_folder") # Apply setwd function
getwd() # Checking new working directory
write.csv2(1:5, "some_data_1.csv") # Write csv file to path
my_path <- "C:/Users/Joach/Desktop/my_folder" # Save path
write.csv2(1:5, # Write csv file to path
paste0(my_path, "/some_data_2.csv"))
Follow me on Social Media:
Facebook - Statistics Globe Page: / statisticsglobecom
Facebook - Group for Discussions & Questions: / statisticsglobe
LinkedIn - Statistics Globe Page: / statisticsglobe
LinkedIn - Group for Discussions & Questions: / 12555223
Twitter: / joachimschork
Music by bensound.com
WHAT A GREAT EXPLANATION! THANKS.
That's great to hear! Thank you very much for the feedback.
Your video is very helpful thank you so much
Thank you so much for the kind comment! Glad it was helpful!
Amazing👍
Thanks a lot, glad you like it! :)
I have a code which has several file paths or directories being read in and I want to change the same, one subfolder in each path. Instead of manually changing them one by one, I’ve assigned it as a value, say x
Hey, could you please share your code and the error message that is returned?
@@StatisticsGlobe thanks for your reply! code is this:
Quarter
I believe the problem is due to the way how you use quotation marks. Does this work for you? Test
I've tried to change the working directory in RStudio from "/cloud/project" to a directory (file ) I first set up on an external hard drive, and then (when that wouldn't work) on my desktop. Neither will work. Any suggestions?
Hello,
If you have trouble with setting a working directory you can also do it manually via the menu bar in Rstudio. Click on "Session" then "Set Working Directory" then you can pick "To Source File Section" or click on "Choose Directory" to set the location of preference.
Regards,
Cansu
What is the "1:5" that you put in the write.csv2 function?
Hello,
Sorry for the late response. It is our sample data. It could also be defined explicitly as follows:
data
doesnt work
Hello,
Could you please share the code and the error you received?
Best,
Cansu
sure can't, but I did figure out what I was doing wrong. I was trying to set the file location on my computer while using R online. I just switch to R studio on my desktop and I was able to find the file location.@@cansustatisticsglobe
Hello,
For some reason, RUclips blocked your previous comment. I have just realized it. Although I have approved it now, I still can't see it here. But as far as I read, you fixed the problem already. Is it correct?
Best,
Cansu
@@cansustatisticsglobe Hello I seem to be having the same issue as beachlife. I am using posit cloud and the directory doesn't change for me. It is currently stuck on /cloud.project. @beachlife8367 are you taking the Coursera course?