Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR for support commandArgs #32

Closed
jangorecki opened this issue Sep 23, 2015 · 8 comments
Closed

FR for support commandArgs #32

jangorecki opened this issue Sep 23, 2015 · 8 comments

Comments

@jangorecki
Copy link

While argv is somehow clear way it requires the R script to be adjusted to be called from littler. littler could hook the commandArgs function and inject own argv it would allow running scripts originally written for Rscript - more portable.

@eddelbuettel
Copy link
Owner

littler predates Rscript. I have little interest in this.

Plus, if you use a proper tool like docopt for R then it is handled for you.

@jangorecki
Copy link
Author

Thanks for info. Instead of new dependency the following would if(!exists("argv")) argv = commandArgs(TRUE) allows portability of R scripts.
Leaving for reference:

if(!exists("argv")) argv = commandArgs(TRUE) else argv = as.character(argv)
cat(str(argv))
q("no")

as.character is added to match case of no input argument where argv would be NULL while commandArgs(T) would be character(0).

@eddelbuettel
Copy link
Owner

Thanks. I stuck that onto the wiki.

@eddelbuettel
Copy link
Owner

I added some comments on the wiki. The more I think about it, the less sense it makes.

r always has argv but not commandArgs(TRUE):

edd@max:~$ r -e'print(argv); print(commandArgs(TRUE))' a b c
[1] "a" "b" "c"
character(0)
edd@max:~$ 

Did you mean to assign the other way?

@jangorecki
Copy link
Author

I mean a R code which will works the same for both r and Rscript.

@eddelbuettel
Copy link
Owner

Should the setting of argv then be added to Rscript instead?

@jangorecki
Copy link
Author

Yes, but changing Rscript behaviour seems to be much harder than adjusting each R script to work for both r and Rscript.
argv seems to be way to go as it is widely adopted outside of R already. Should I fill FR for it somewhere? in bugzilla??

@eddelbuettel
Copy link
Owner

Not sure. You may want to discuss it on r-devel first as you will need a sponsor for the change in any event.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants