What is the best practice for efficient file upload in R (Windows)

When I want to upload a file to R, which would be an effective way to do this programmatically (or half-program), and not just manually copy the path and switch \to /so that R can read it (since it \is a control character in R)

One method specified by @Roland usesscan

list.files(scan(file=file(description = "clipboard"), what = "character", allowEscapes = FALSE))

Who needs modifications if the path contains a space, for example

"C: \ Users \ David Arenburg \"

0
source share
2 answers

normalizepath maybe what you are looking for:

> normalizePath(c(R.home(), tempdir()))
[1] "C:\\Program Files\\R\\R-3.1.0"                    
[2] "C:\\Users\\john\\AppData\\Local\\Temp\\RtmpysKuFi"
> normalizePath(c(R.home(), tempdir()), winslash = '/')
[1] "C:/Program Files/R/R-3.1.0"                 
[2] "C:/Users/john/AppData/Local/Temp/RtmpysKuFi"

readClipboard, Windows . , Windows, , :

> readClipboard()
[1] "C:\\Users\\john\\AppData\\Local\\Temp"

`normalizePath .

+2

, select.files(), , normalizePath(), R .

0

Source: https://habr.com/ru/post/1652589/


All Articles