I use bash
to transfer data via Rscript
as follows: cat random.csv | Rscript test.R arg >| delete.csv
cat random.csv | Rscript test.R arg >| delete.csv
My goal is to use the R
readr
package to read stdin and write stdout. I found the answer to stdin here .
test.r
#!/usr/bin/Rscript suppressMessages(library(readr)) args <- commandArgs(trailingOnly = TRUE) df.in <- read_csv(file("stdin")) write_csv(df.in, path = stdout())
In the above code, the following command line error message appears:
Error message
Error in path.expand(path) : invalid 'path' argument Calls: write_csv -> write_delim -> normalizePath -> path.expand Execution halted
I also tried write_csv(df.in, file("stdout"))
and write_csv(df.in, stdout())
, creating the same error message.
For reproducibility, here is a link to random.csv
Definition of variables, WHO for the Global Tuberculosis Report [43kb]
source share