Setting up a Working Directory in R: How to Set up Working Directories in R Using RStudio Menus and Functions. Practice with Free Dataset: ( 👍🏼Best Statistics & R Programming Language Tutorials: ( )
►► Like to support us? You can Donate ( Share our Videos, Leave us a Comment and Give us a Like or Write us a Review! Either way We Thank You!
In this tutorial, You will learn to use the “getwd”, “setwd”, “save.image”, and “load” functions in R and R Studio menus.
Table of Content:
0:00:07 what are “working directories” in R Statistical Software and why use them
0:00:49 how to find the current working directory in R using the “getwd” function
0:01:03 how to set a working directory in R using “setwd” command
0:02:15 how to set up working directories in R using RStudio menu items
0:03:26 how to save the current “workspace image” in R using the “save.image” function
0:04:38 how to let R know that a file is a workspace image using “.Rdata” extension
0:04:55 how to use the menu items in RStudio to save a workspace image
0:05:32 how to remove all items from the current workspace using the (“rm(list=ls()”) command
0:05:42 how to remove all items from the current workspace using RStudio menus
0:05:54 how to quit R using RStudio menus
0:05:58 how to quit R using “q” command
0:07:05 how to load the previous workspace image using the “load” command
0:07:30 how to load the previous workspace image using the “file.choose” command
0:07:51 how to load the previous workspace image using RStudio menus
This video is a tutorial for programming in R Statistical Software for beginners.
► ► Watch More:
► Intro to Statistics Course:
►Data Science with R
►Getting Started with R (Series 1):
►Graphs and Descriptive Statistics in R (Series 2):
►Probability distributions in R (Series 3):
►Bivariate analysis in R (Series 4):
►Linear Regression in R (Series 5):
►ANOVA Concept and with R
►Hypothesis Testing:
Follow MarinStatsLectures
Subscribe:
website:
Facebook:
Twitter:
Instagram:
Our Team:
Content Creator: Mike Marin (B.Sc., MSc.) Senior Instructor at UBC.
Producer and Creative Manager: Ladan Hamadani (B.Sc., BA., MPH)
These videos are created by #marinstatslectures to support some courses at The University of British Columbia (UBC) (#IntroductoryStatistics and #RVideoTutorials for Health Science Research), although we make all videos available to the everyone everywhere for free.
Thanks for watching! Have fun and remember that statistics is almost as beautiful as a unicorn!
source

Very clear and useful! Thank you very much!
Thankyou it was very helpful
When I give the command save.image("Firstproject.Rdata"),
Im facing unexpected invalid token ij save.image (""……
What should I do,sir?
THANKS FOR YOUR BRIEF EXPLANATION
How do you change the working directory from cloud to local disc on Rstudio cloud online?
eroe
thanks for such a great sequence of steps to follow to command on R… i am so glad to find you after weeks, finally got a platform to better learn.
quick and clear
best boy!
Ok so for anyone who had issues with not being administrator on his Windows based computer. I had issues changing the directory with messages like "cannot change directory".
You cannot use a folder which contains your operating system, so generally your SSD. This has caused countless issues for me to even get programs running properly and also R suffers from this. And people wonder why Apple has a market…. fk MS honestly (this has been an issue for years now)
For some reason R does not let me edit anything in the console. Any idea why?
What should I do? Untitled1 coming again and again. I am unable to set working directory. I need some more
I needed a detail set up for this for one of my homework's in one of my courses as my Professor didn't go over how to do this. Appreciate you making this video!
Hi Marin, seems very simple when you explain. But all that I got just the first line correct: setwd(pathway). Beyond that, not able to change the name for simplifications. R responds by saying "cannot change working directory". Where am I going wrong?
Thank you in advance
This is a blessing in my life. So detailed and clear to understand. I found it very simple to understand as a beginner
Thanks a lot! I was so frustrated with the lack of proper instructions online when I found this video.
Each project should have .rproj file. It location is your root directory of project. From here you can use relative paths to different folders. No setwd() needed whatsoever.
In this R tutorial, we will learn to set up working directories in R Using RStudio Menus and R Functions such as "getwd", "setwd", "save.image", and "load”. Make sure to practice with Free Dataset: (https://statslectures.com/r-scripts-datasets) 🤓If Like to support us you can Donate (https://bit.ly/2CWxnP2), Share our Videos, Leave us a Comment, Give us a Like 👍🏼 or write us a review! Either way We Thank You!
very very useful, saved me a lot of time with this!
The video was really helpful Martin…Thank you!!
1. Read multiple json files into a working directory for further converting into a dataset.
I have files text1, text2, text3 in the directory json
. I dont know how to do it. please teach me how
Hi Marin.. Suppose I have created many large datasets in one session and then I choose to save this workspace as image. Now will this image file occupy space equivalent to spaces occupied by those large datasets in total!
Very nicely explained. Best wishes from India
When I save the workspace they say no working directory found.
thank you
Thank you so much Mike for these great videos.
hello sir while installing a library it shows the following path please help
install.packages("beamplot")
Warning in install.packages :
unable to access index for repository http://cran.rstudio.com/src/contrib:
cannot open URL 'http://cran.rstudio.com/src/contrib/PACKAGES'
Warning in install.packages :
unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/src/contrib:
cannot open URL 'http://www.stats.ox.ac.uk/pub/RWin/src/contrib/PACKAGES'
Installing package into ‘C:/Users/Swar/Documents/R/win-library/3.4’
(as ‘lib’ is unspecified)
Warning in install.packages :
unable to access index for repository http://cran.rstudio.com/src/contrib:
cannot open URL 'http://cran.rstudio.com/src/contrib/PACKAGES'
Warning in install.packages :
unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/src/contrib:
cannot open URL 'http://www.stats.ox.ac.uk/pub/RWin/src/contrib/PACKAGES'
Warning in install.packages :
package ‘beamplot’ is not available (for R version 3.4.3)
Warning in install.packages :
unable to access index for repository http://cran.rstudio.com/bin/windows/contrib/3.4:
cannot open URL 'http://cran.rstudio.com/bin/windows/contrib/3.4/PACKAGES'
Warning in install.packages :
unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/3.4:
cannot open URL 'http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/3.4/PACKAGES'
Dear Mike,
When I run the summary of z, for Smoke, Gender and Caesarean I get class and mode as "Character" and not the numbers visible in the video. Can you please help?
There's one thing I don't understand. If you can use "=" to assign a value to a variable, why does everyone use "<-"? "=" is much more intuitive and is used in most programming languages. As I'm learning R I'm getting into the habit of using "<-" since everyone uses it and I figure there must be a reason.
I really appreciate your this awesome lecture videos !!
Why does RStudio on my pc always open with an already loaded workspace?
Thanks for this video. I have questions: (a) Is it always necessary to set the working directory when starting a new session. (b) Can different files (Rmd, Rscript or Rdata) be stored under a same folder for one project? (c) Personally I choose to import my files from a directory rather the file.choose, as I always in the end like to knit the Rmd document to word or PDF. If i use file.choose to import, i always get error when knitting. I guess this is because in this way, a pop up window appears to import data. Maybe R couldn't recognise this when knitting. (d) could you please do some videos on absolute and relative path for wd. Would really appreciate if you can reply. Thank you.
Thanks for these videos, they're really easy to follow and understand.
Thanks for the great instructions. One suggestion… It might be better to have this video a bit earlier.
Up to this video, I had difficulties in saving my working space and the progress I had sofar from previous videos.
Just recognized: On Windows there migth be an slash backslash issue.
When you copy a pathname from Windows file explorer it gives you:
C:UsersIkaetc. <– these are backslashes !! R seems to not like them. So I altered:
C:/Users/Ika/etc. and there we go, R is happy again 🙂
Do you know any method to get path for the standard wd? (not to set it)
When I try setwd, I got this error: Error in setwd("~/Desktop") : cannot change working directory
However, I tried :> setwd("C:/Users/chichi/Desktop") # It works. Can anyone helps me?
Thank you for your nice lectures. It really helped me a lot.
This is super helpful. Thank you for making these videos! It saves me sooo many hours!
Very clear and helpful, thank you!
can u plz do this specifically for windows ??it is showing lots of errors
Great
Mr Marin! You are just the bomb! I am loving this like ice cream. God bless you for saving a career.
Hi Mike, thanks for the video; I was wondering if there is a way to save the contents thats already input in the console? The load function couldnot pull that one off. Thanks!
I love to learn from yr videos thanks for uploading such a great video.
Hi Mike,
I am enjoying your videos on R, but i am having some trouble while I am working through this video. Every time I type in MeanAge <- mean(Age) I get this error:
Error in mean(Age) : object 'Age' not found
What does this mean? and how can I fix it