-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
257 lines (187 loc) · 6.56 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
---
output: github_document
# To center the elements correctly on GitHub, we need to post-process
# <p></p> blocks to remove blank lines after <p> and add two leading spaces
# before each <a> tag.
knit: |
(function(inputFile, encoding) {
rmarkdown::render(input = inputFile, encoding = encoding)
output <- paste0(basename(tools::file_path_sans_ext(inputFile)), ".md")
content <- paste0(readLines(output), collapse = "\n")
matches <- gregexpr("(?s)<p[^>]*>.*?</p>", content, perl = TRUE)
match_texts <- regmatches(content, matches)[[1]]
process_p_block <- function(block) {
block <- gsub("(<p[^>]*>)[ \\t]*\\n([ \\t]*\\n)*", "\\\\1\n", block)
block <- gsub("(<a[^>]*>)", " \\\\1", block)
block
}
modified_texts <- vapply(match_texts, process_p_block, character(1))
regmatches(content, matches)[[1]] <- modified_texts
writeLines(content, con = output)
invisible(output)
})
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include=FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
echo = FALSE
)
```
# r-windows-paths
<a href="https://nanx.me/blog/post/r-windows-paths/">
<img src="images/banner.png" alt="r-windows-paths">
</a>
<p align="center">
<a href="#example-versions"><strong>Example versions</strong></a> ·
<a href="#configure-and-verify"><strong>Configure and verify</strong></a>
</p>
<p align="center">
<a href="#r"><strong>R</strong></a> ·
<a href="#rtools"><strong>Rtools</strong></a> ·
<a href="#tinytex"><strong>TinyTeX</strong></a> ·
<a href="#miktex"><strong>MiKTeX</strong></a> ·
<a href="#pandoc"><strong>Pandoc</strong></a> ·
<a href="#quarto"><strong>Quarto</strong></a> ·
<a href="#git"><strong>Git</strong></a>
</p>
Essential R command-line tool paths on Windows.
This information can help setting up the `PATH` environment variable
for seamless command-line access.
## Example versions
Some of the paths below are specific to the installed software version.
We use these software version examples:
```{r}
str_extract_first <- function(x, pattern) {
m <- regexec(pattern, text = x, perl = TRUE)
regmatches(x, m = m)[[1]][2]
}
get_r_version <- function() {
"http://cran.r-project.org/src/base/VERSION-INFO.dcf" |>
url() |>
read.dcf() |>
as.data.frame() |>
getElement(name = "Release")
}
get_rtools_version <- function() {
version_string <- "https://raw.githubusercontent.com/r-windows/rtools-chocolatey/master/src/rtools.nuspec" |>
curl::curl_fetch_memory() |>
getElement(name = "content") |>
rawToChar() |>
str_extract_first(pattern = "<version>(.*?)</version>")
parts <- strsplit(version_string, "\\.")[[1]]
paste0(parts[1], parts[2])
}
get_rstudio_version <- function() {
version_string <- "http://download1.rstudio.org/current.ver" |>
curl::curl_fetch_memory() |>
getElement(name = "content") |>
rawToChar()
parts <- strsplit(trimws(version_string), "\\+")[[1]]
major <- parts[1]
minor <- strsplit(parts[2], "\\.")[[1]][1]
list(major = major, minor = minor)
}
r_version <- get_r_version()
rtools_version <- get_rtools_version()
rstudio_version <- get_rstudio_version()
rstudio_version_major <- rstudio_version$major
rstudio_version_minor <- rstudio_version$minor
```
- R `r r_version`
- Rtools`r rtools_version`
- RStudio Desktop `r sprintf("%s+%s", rstudio_version_major, rstudio_version_minor)`
## Key paths
### R
`R.exe` and `Rscript.exe` for running `R CMD build` and `R CMD check`.
R release version `r r_version`:
```batchfile
C:\Program Files\R\R-`r r_version`\bin
```
R-devel:
```batchfile
C:\Program Files\R\R-devel\bin
```
### Rtools
C/C++/Fortran toolchain for building R and R packages from source.
Contains `gcc`, `g++`, `gfortran`:
```batchfile
C:\rtools`r rtools_version`\x86_64-w64-mingw32.static.posix\bin
```
Contains Texinfo (`texi2dvi`, `texi2pdf`) required by `R CMD check`,
and GNU Make (`make`) required for building R from source:
```batchfile
C:\rtools`r rtools_version`\usr\bin
```
### TinyTeX
TeX distribution binaries for LaTeX support.
Contains `pdflatex` required by `R CMD check` and for building R from source.
```batchfile
C:\Users\%USERNAME%\AppData\Roaming\TinyTeX\bin\windows
```
### MiKTeX
TeX distribution binaries for LaTeX support.
Contains `pdflatex` required by `R CMD check` and for building R from source.
MiKTeX installed via `choco install miktex` or standalone installer (all users):
```batchfile
C:\Program Files\MiKTeX\miktex\bin\x64
```
MiKTeX installed via standalone installer (current user):
```batchfile
C:\Users\%USERNAME%\AppData\Local\Programs\MiKTeX\miktex\bin\x64
```
### Pandoc
pandoc installed via `choco install pandoc` or standalone installer:
```batchfile
C:\Users\%USERNAME%\AppData\Local\Pandoc
```
pandoc distributed with RStudio Desktop (installer):
```batchfile
C:\Program Files\RStudio\resources\app\bin\quarto\bin\tools
```
pandoc distributed with RStudio Desktop (zip):
```batchfile
C:\Users\%USERNAME%\RStudio-`r sprintf("%s-%s", rstudio_version_major, rstudio_version_minor)`\resources\app\bin\quarto\bin\tools
```
pandoc distributed with Quarto installed via `choco install quarto`:
```batchfile
C:\ProgramData\chocolatey\lib\quarto\tools\bin\tools
```
pandoc distributed with Quarto installed via Quarto standalone installer:
```batchfile
C:\Users\%USERNAME%\AppData\Local\Programs\Quarto\bin\tools
```
### Quarto
Quarto installed via `choco install quarto`:
```batchfile
C:\ProgramData\chocolatey\lib\quarto\tools\bin
```
Quarto installed via Quarto standalone installer:
```batchfile
C:\Users\%USERNAME%\AppData\Local\Programs\Quarto\bin
```
Quarto distributed with RStudio Desktop (installer):
```batchfile
C:\Program Files\RStudio\resources\app\bin\quarto\bin
```
Quarto distributed with RStudio Desktop (zip):
```batchfile
C:\Users\%USERNAME%\RStudio-`r sprintf("%s-%s", rstudio_version_major, rstudio_version_minor)`\resources\app\bin\quarto\bin
```
### Git
For interacting with Git repositories.
Git for Windows installed via `choco install git` or standalone installer:
```batchfile
C:\Program Files\Git\cmd
```
## Configure and verify
1. Locate the paths on your system.
- Open File Explorer and navigate to the directories listed above.
- Verify that the paths exist and contain the expected executables.
1. Add relevant paths to your system's `PATH` environment variable
and verify the setup.
- For a step-by-step guide with screenshots, see
[how to set the `PATH` environment variable in Windows](path.md).
Now you should be able to use R and its associated tools from the CLI
without specifying full paths.