News for hackers. Stuff that matters.
Re:A Quick Introduction to R by awild on Sunday February 06, 2022 @02:37PM (#30236128)
Maybe someone can help me with this, how do you integrate r as a cli tool? I'm in a mostly R shop but its integration is so confusing and/or bad with other tools that we usually just rewrite everything in python for integration (which obviously is a huge waste of time). R packages etc have me as an outsider confused,though seem like the obvious choice?
Re:A Quick Introduction to R by dm319 on Sunday February 06, 2022 @03:35PM (#30236711)
I love R, nothing better for data analysis, stats and plotting. However, if I was making software for other people to use, repeatedly, I would probably pick another language. The R language does have breaking changes, especially in commonly used packages.
Re:A Quick Introduction to R by fastaguy88 on Sunday February 06, 2022 @03:25PM (#30236632)
You can always write: Rscript --vanilla your_r_script.r (and #!/usr/bin/env Rscript --vanilla )

Command line arguments are available as:

args <- commandArgs(trailingOnly=TRUE)

And there are three getopt()-like packages: getopt, optparse, and argparse.

Re:A Quick Introduction to R by awild on Monday February 07, 2022 @02:40AM (#30241510)
We've done that but someone used relative includes/require statements and everything broke. It's exceptionally annoying.
Re:A Quick Introduction to R by eliashaddad on Monday February 14, 2022 @09:56PM (#30342120)
In this case you should probably use the "here" or the "rprojroot" packages (libraries in conventional R parlance). They both simplify the usage of relative paths inside a project/repository.

If you have a project root with the folders code, data, etc and are running a project on /path/root/code, you can then just call data_dir <- here::here("data") for the data folder, as the here package uses several always to find the root of a project (e.g., looking for a .git folder).

Re:A Quick Introduction to R by gompertz on Sunday February 06, 2022 @02:40PM (#30236167)
Personally I use my programming language of choice to generate a ".r" script and then use the os exec system call of said language to call Rscript scriptname.r... If I'm understanding your question correctly.