{"id":5283,"date":"2021-05-10T09:32:10","date_gmt":"2021-05-10T04:02:10","guid":{"rendered":"https:\/\/python-programs.com\/?p=5283"},"modified":"2021-11-22T18:49:06","modified_gmt":"2021-11-22T13:19:06","slug":"r-set-working-directory","status":"publish","type":"post","link":"https:\/\/python-programs.com\/r-set-working-directory\/","title":{"rendered":"R: Set working directory"},"content":{"rendered":"

How to set work directory in R studio ?<\/h2>\n

In this article we are going to discuss about how we can set work directory R and also we will verify if that directory has been set perfectly or not. So, let’s start exploring the topic.<\/p>\n

R is an interpreted programming language which is created by Ross Ihaka and Robert Gentleman. This programming language and open source environment is used for statistical computing, graphical presentation, data analytics and scientific research.<\/p>\n

R studio is an\u00a0 Integrated Development Environment (IDE) which provides free and open source tools for Rn language.<\/p>\n

When working with R language sometimes we need to work with external files and for that we have to set that file directory as working directory otherwise the file won’t be accessible.<\/p>\n

So, let’s see how we can set a directory as an working directory in R studio.<\/p>\n

Setting up a Working Directory in R studio :<\/h3>\n

Steps to set working directory in R studio.<\/p>\n

    \n
  1. Go to session menu.<\/li>\n
  2. Select set working directory.<\/li>\n
  3. Then select Choose Directory.<\/li>\n
  4. From there browse the directory.<\/li>\n<\/ol>\n

    Set up Working Directory in R using setwd() function :<\/h3>\n

    By using setwd()<\/code> function we can set the working directory.<\/p>\n

    Syntax : setwd<\/span>(<\/span>\"D:\/R_workingfile\"<\/span>)<\/span><\/pre>\n

    For example, we have a directory \/Users\/BtechGeeks<\/code> and we want to set it as\u00a0 working directory then we can do it like this<\/p>\n

    # command to set working directory.\r\nsetwd(\"Users\/BtechGeeks\"<\/code>)<\/code><\/pre>\n

    If the path does not exist :<\/h3>\n

    If you want to set a directory as working directory but that directory does not exist then it will give Error.<\/p>\n

    For example, a directory \/Users\/Btech<\/code> which does not exists but we want to make it working directory.<\/p>\n

    Then<\/p>\n

    # Directory does not exist\r\nsetwd(\"\/Users\/Btech\")<\/pre>\n
    # Raising error as directory does not exit\r\nError <\/span>in<\/span> setwd<\/span>(<\/span>\"\/Users\/Btech\"<\/span>)<\/span> :<\/span> cannot change working directory<\/span><\/pre>\n

    Verifying the current working directory is set in R :<\/h3>\n

    We can use getwd()<\/code> function to check the current working directory.<\/p>\n

    If it returns the correct directory then the working directory has been set perfectly.<\/p>\n

    \n
    # It will give the current working directory\r\ngetwd<\/span>()\r\n>> \"\/Users\/BtechGeeks\"<\/code><\/span><\/span><\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"

    How to set work directory in R studio ? In this article we are going to discuss about how we can set work directory R and also we will verify if that directory has been set perfectly or not. So, let’s start exploring the topic. R is an interpreted programming language which is created by …<\/p>\n

    R: Set working directory<\/span> Read More »<\/a><\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[5],"tags":[],"yoast_head":"\nR: Set working directory - Python Programs<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/python-programs.com\/r-set-working-directory\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"R: Set working directory - Python Programs\" \/>\n<meta property=\"og:description\" content=\"How to set work directory in R studio ? In this article we are going to discuss about how we can set work directory R and also we will verify if that directory has been set perfectly or not. So, let’s start exploring the topic. R is an interpreted programming language which is created by … R: Set working directory Read More »\" \/>\n<meta property=\"og:url\" content=\"https:\/\/python-programs.com\/r-set-working-directory\/\" \/>\n<meta property=\"og:site_name\" content=\"Python Programs\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/btechgeeks\" \/>\n<meta property=\"article:published_time\" content=\"2021-05-10T04:02:10+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-11-22T13:19:06+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@btech_geeks\" \/>\n<meta name=\"twitter:site\" content=\"@btech_geeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Satyabrata Jena\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https:\/\/python-programs.com\/#organization\",\"name\":\"BTech Geeks\",\"url\":\"https:\/\/python-programs.com\/\",\"sameAs\":[\"https:\/\/www.instagram.com\/btechgeeks\/\",\"https:\/\/www.linkedin.com\/in\/btechgeeks\",\"https:\/\/in.pinterest.com\/btechgeek\/\",\"https:\/\/www.youtube.com\/channel\/UC9MlCqdJ3lKqz2p5114SDIg\",\"https:\/\/www.facebook.com\/btechgeeks\",\"https:\/\/twitter.com\/btech_geeks\"],\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/python-programs.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/python-programs.com\/wp-content\/uploads\/2020\/11\/BTechGeeks.png\",\"contentUrl\":\"https:\/\/python-programs.com\/wp-content\/uploads\/2020\/11\/BTechGeeks.png\",\"width\":350,\"height\":70,\"caption\":\"BTech Geeks\"},\"image\":{\"@id\":\"https:\/\/python-programs.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/python-programs.com\/#website\",\"url\":\"https:\/\/python-programs.com\/\",\"name\":\"Python Programs\",\"description\":\"Python Programs with Examples, How To Guides on Python\",\"publisher\":{\"@id\":\"https:\/\/python-programs.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/python-programs.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/python-programs.com\/r-set-working-directory\/#webpage\",\"url\":\"https:\/\/python-programs.com\/r-set-working-directory\/\",\"name\":\"R: Set working directory - Python Programs\",\"isPartOf\":{\"@id\":\"https:\/\/python-programs.com\/#website\"},\"datePublished\":\"2021-05-10T04:02:10+00:00\",\"dateModified\":\"2021-11-22T13:19:06+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/python-programs.com\/r-set-working-directory\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/python-programs.com\/r-set-working-directory\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/python-programs.com\/r-set-working-directory\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/python-programs.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"R: Set working directory\"}]},{\"@type\":\"Article\",\"@id\":\"https:\/\/python-programs.com\/r-set-working-directory\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/python-programs.com\/r-set-working-directory\/#webpage\"},\"author\":{\"@id\":\"https:\/\/python-programs.com\/#\/schema\/person\/0f6d731bda7051ce3586f71299f391cd\"},\"headline\":\"R: Set working directory\",\"datePublished\":\"2021-05-10T04:02:10+00:00\",\"dateModified\":\"2021-11-22T13:19:06+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/python-programs.com\/r-set-working-directory\/#webpage\"},\"wordCount\":298,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/python-programs.com\/#organization\"},\"articleSection\":[\"Python\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/python-programs.com\/r-set-working-directory\/#respond\"]}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/python-programs.com\/#\/schema\/person\/0f6d731bda7051ce3586f71299f391cd\",\"name\":\"Satyabrata Jena\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/python-programs.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/c1bf8033ec357d085f41815bee1625cc?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/c1bf8033ec357d085f41815bee1625cc?s=96&d=mm&r=g\",\"caption\":\"Satyabrata Jena\"},\"url\":\"https:\/\/python-programs.com\/author\/satyabrata\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"R: Set working directory - Python Programs","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/python-programs.com\/r-set-working-directory\/","og_locale":"en_US","og_type":"article","og_title":"R: Set working directory - Python Programs","og_description":"How to set work directory in R studio ? In this article we are going to discuss about how we can set work directory R and also we will verify if that directory has been set perfectly or not. So, let’s start exploring the topic. R is an interpreted programming language which is created by … R: Set working directory Read More »","og_url":"https:\/\/python-programs.com\/r-set-working-directory\/","og_site_name":"Python Programs","article_publisher":"https:\/\/www.facebook.com\/btechgeeks","article_published_time":"2021-05-10T04:02:10+00:00","article_modified_time":"2021-11-22T13:19:06+00:00","twitter_card":"summary_large_image","twitter_creator":"@btech_geeks","twitter_site":"@btech_geeks","twitter_misc":{"Written by":"Satyabrata Jena","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Organization","@id":"https:\/\/python-programs.com\/#organization","name":"BTech Geeks","url":"https:\/\/python-programs.com\/","sameAs":["https:\/\/www.instagram.com\/btechgeeks\/","https:\/\/www.linkedin.com\/in\/btechgeeks","https:\/\/in.pinterest.com\/btechgeek\/","https:\/\/www.youtube.com\/channel\/UC9MlCqdJ3lKqz2p5114SDIg","https:\/\/www.facebook.com\/btechgeeks","https:\/\/twitter.com\/btech_geeks"],"logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/python-programs.com\/#\/schema\/logo\/image\/","url":"https:\/\/python-programs.com\/wp-content\/uploads\/2020\/11\/BTechGeeks.png","contentUrl":"https:\/\/python-programs.com\/wp-content\/uploads\/2020\/11\/BTechGeeks.png","width":350,"height":70,"caption":"BTech Geeks"},"image":{"@id":"https:\/\/python-programs.com\/#\/schema\/logo\/image\/"}},{"@type":"WebSite","@id":"https:\/\/python-programs.com\/#website","url":"https:\/\/python-programs.com\/","name":"Python Programs","description":"Python Programs with Examples, How To Guides on Python","publisher":{"@id":"https:\/\/python-programs.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/python-programs.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/python-programs.com\/r-set-working-directory\/#webpage","url":"https:\/\/python-programs.com\/r-set-working-directory\/","name":"R: Set working directory - Python Programs","isPartOf":{"@id":"https:\/\/python-programs.com\/#website"},"datePublished":"2021-05-10T04:02:10+00:00","dateModified":"2021-11-22T13:19:06+00:00","breadcrumb":{"@id":"https:\/\/python-programs.com\/r-set-working-directory\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/python-programs.com\/r-set-working-directory\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/python-programs.com\/r-set-working-directory\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/python-programs.com\/"},{"@type":"ListItem","position":2,"name":"R: Set working directory"}]},{"@type":"Article","@id":"https:\/\/python-programs.com\/r-set-working-directory\/#article","isPartOf":{"@id":"https:\/\/python-programs.com\/r-set-working-directory\/#webpage"},"author":{"@id":"https:\/\/python-programs.com\/#\/schema\/person\/0f6d731bda7051ce3586f71299f391cd"},"headline":"R: Set working directory","datePublished":"2021-05-10T04:02:10+00:00","dateModified":"2021-11-22T13:19:06+00:00","mainEntityOfPage":{"@id":"https:\/\/python-programs.com\/r-set-working-directory\/#webpage"},"wordCount":298,"commentCount":0,"publisher":{"@id":"https:\/\/python-programs.com\/#organization"},"articleSection":["Python"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/python-programs.com\/r-set-working-directory\/#respond"]}]},{"@type":"Person","@id":"https:\/\/python-programs.com\/#\/schema\/person\/0f6d731bda7051ce3586f71299f391cd","name":"Satyabrata Jena","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/python-programs.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/c1bf8033ec357d085f41815bee1625cc?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c1bf8033ec357d085f41815bee1625cc?s=96&d=mm&r=g","caption":"Satyabrata Jena"},"url":"https:\/\/python-programs.com\/author\/satyabrata\/"}]}},"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/python-programs.com\/wp-json\/wp\/v2\/posts\/5283"}],"collection":[{"href":"https:\/\/python-programs.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/python-programs.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/python-programs.com\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/python-programs.com\/wp-json\/wp\/v2\/comments?post=5283"}],"version-history":[{"count":1,"href":"https:\/\/python-programs.com\/wp-json\/wp\/v2\/posts\/5283\/revisions"}],"predecessor-version":[{"id":5284,"href":"https:\/\/python-programs.com\/wp-json\/wp\/v2\/posts\/5283\/revisions\/5284"}],"wp:attachment":[{"href":"https:\/\/python-programs.com\/wp-json\/wp\/v2\/media?parent=5283"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/python-programs.com\/wp-json\/wp\/v2\/categories?post=5283"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/python-programs.com\/wp-json\/wp\/v2\/tags?post=5283"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}