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

Комментарии • 19

  • @alaminafendy6071
    @alaminafendy6071 10 месяцев назад +1

    WHAT A GREAT EXPLANATION! THANKS.

  • @TaraGhimite
    @TaraGhimite 4 месяца назад +1

    Your video is very helpful thank you so much

    • @StatisticsGlobe
      @StatisticsGlobe  4 месяца назад

      Thank you so much for the kind comment! Glad it was helpful!

  • @infotainment7246
    @infotainment7246 2 года назад +2

    Amazing👍

  • @ruairimccay4120
    @ruairimccay4120 Месяц назад +1

    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

    • @StatisticsGlobe
      @StatisticsGlobe  Месяц назад

      Hey, could you please share your code and the error message that is returned?

    • @ruairimccay4120
      @ruairimccay4120 Месяц назад +1

      @@StatisticsGlobe thanks for your reply! code is this:
      Quarter

    • @StatisticsGlobe
      @StatisticsGlobe  Месяц назад

      I believe the problem is due to the way how you use quotation marks. Does this work for you? Test

  • @beachlife8367
    @beachlife8367 Год назад +1

    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?

    • @cansustatisticsglobe
      @cansustatisticsglobe Год назад +2

      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

  • @xxxx8901
    @xxxx8901 Год назад +1

    What is the "1:5" that you put in the write.csv2 function?

    • @cansustatisticsglobe
      @cansustatisticsglobe Год назад

      Hello,
      Sorry for the late response. It is our sample data. It could also be defined explicitly as follows:
      data

  • @SaltyNicky
    @SaltyNicky 9 месяцев назад +1

    doesnt work

    • @cansustatisticsglobe
      @cansustatisticsglobe 9 месяцев назад

      Hello,
      Could you please share the code and the error you received?
      Best,
      Cansu

    • @SaltyNicky
      @SaltyNicky 9 месяцев назад

      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

    • @cansustatisticsglobe
      @cansustatisticsglobe 9 месяцев назад

      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

    • @Alejandro_Gonzalez009
      @Alejandro_Gonzalez009 8 месяцев назад

      @@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?