Setting Up Working Directory in R | R Tutorial 1.11 | MarinStatsLectures



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

46 Comments

  1. 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)

  2. 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

  3. 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

  4. 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!

  5. 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'

  6. 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?

  7. 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.

  8. 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.

  9. 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.

  10. 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 🙂

  11. 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?

  12. 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!

  13. 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

Leave a Reply

Your email address will not be published. Required fields are marked *

You might like

© 2026 Cantinho do Vídeo - WordPress Video Theme by WPEnjoy