From ec7a3701c2047c27a6553fecc3badbc7804cf5d6 Mon Sep 17 00:00:00 2001 From: "Y. Yu" <54338793+PursuitOfDataScience@users.noreply.github.com> Date: Fri, 7 Jan 2022 20:46:26 -0500 Subject: [PATCH] Update 02-set-up.Rmd Fixed the Windows path part and added an extra sentence. --- 02-set-up.Rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/02-set-up.Rmd b/02-set-up.Rmd index ffe00f9..be63843 100644 --- a/02-set-up.Rmd +++ b/02-set-up.Rmd @@ -319,7 +319,7 @@ file.edit(".Rprofile") # edit project specific .Rprofile ``` ```{block, file.path, type="rmdwarning"} -File paths provided by Windows operating systems will not always work in R. Specifically, if you use a path that contains single backslashes, such as `C:\\DATA\\data.csv`, as provided by Windows, this will generate the error: `Error: unexpected input in "C:\\"`. To overcome this issue R provides two functions, `file.path()` and `normalizePath()`. The former can be used to specify file locations without having to use symbols to represent relative file paths, as follows: `file.path("C:", "DATA", "data.csv")`. The latter takes any input string for a file name and outputs a text string that is standard (canonical) for the operating system. `normalizePath("C:/DATA/data.csv")`, for example, outputs `C:\\DATA\\data.csv` on a Windows machine but `C:/DATA/data.csv` on Unix-based platforms. Note that only the latter would work on both platforms so standard Unix file path notation is safe for all operating systems. +File paths provided by Windows operating systems will not always work in R. Specifically, if you use a path that contains single backslashes, such as `C:\DATA\data.csv`, as provided by Windows, this will generate the error: `Error: unexpected input in "C:\"`. To overcome this issue R provides two functions, `file.path()` and `normalizePath()`. The former can be used to specify file locations without having to use symbols to represent relative file paths, as follows: `file.path("C:", "DATA", "data.csv")`. The latter takes any input string for a file name and outputs a text string that is standard (canonical) for the operating system. `normalizePath("C:/DATA/data.csv")`, for example, outputs `C:\\DATA\\data.csv` on a Windows machine but `C:/DATA/data.csv` on Unix-based platforms. Note that only the latter would work on both platforms so standard Unix file path notation is safe for all operating systems. Besides using the aforementioned two functions, an alternative way to specify a path on Windows is to use double backslashes `\\`, i.e. `C:\\DATA\\data.csv`. ``` Editing the `.Renviron` file in the same locations will have the same effect.