yihui / xfun

Miscellaneous R functions
https://yihui.org/xfun/
Other
135 stars 28 forks source link

Add an argument to pass options flag to Rscript_call() #48

Closed cderv closed 3 years ago

cderv commented 3 years ago

This closes #47

I chose to call it rscript_options because it is really to pass some options flag to Rscript at command line. shQuote(c(pkg_file('scripts', 'call-fun.R'), f) is already part of the args passed to system2, so cmd_args seems a bit less specific.

I also added some tests helping with #5

I also added the argument to Rscript_bg() but I am not sure how it works really - did not manage to add a simple test. It is not exported so it is less important.

yihui commented 3 years ago

I also added the argument to Rscript_bg() but I am not sure how it works really - did not manage to add a simple test. It is not exported so it is less important.

That was just from a random thought. I don't have a real use case in mind. Originally I was thinking of running hugo in the background, but later I felt bg_process() was good enough. So you can ignore this function.

cderv commented 3 years ago

In general, I prefer shorter names. Thoughts?

Could it be then just options given the context ?

Rscript_call(c, list(1, 2, 3), options = "--vanilla")

Basically, it will be used only to pass options as described in ?utils::Rscript

That is why the other names did not seem as self-explanatory as rscript_options.

cderv commented 3 years ago

Also tests are not working as I expect in CI - it works locally though. 😞 I'll look at it tomorrow, or you can just remove them for now - it was to start increasing the coverage

cderv commented 3 years ago

I figured out the CI problem. It was quite surprising to me, though. Thanks!

Oh good find ! I did not know that at all.

Retroactively, looking into callr, it has it too and it is not the only variable that could cause issue when running R from within R.