add_argument function takes "." as atomic vector
Closed this issue · 4 comments
Hi,
Argparse on R would be a very convenient tool for me, however I have the following issue when I try to add an argument.
R> parser <- ArgumentParser(description='Processing arguments') R> parser$add_argument('x') Error in .$python_code : $ operator is invalid for atomic vectors
Looking at the add_argument function, the issue doesn't seem obvious to me, can you help?
R> parser$add_argument function (., ...) { .$python_code <- c(.$python_code, sprintf("parser.add_argument(%s)", convert_..._to_arguments("add_argument", ...))) return(invisible(NULL)) } <environment: 0x2e7fb58>
Thanks!
This seems to work only with the version 1.0.7, not the latest
Thanks for the bug report. Not reproducible on my end or on Travis-CI using either the 'oldrel', 'release', or 'development' versions of R.
- Do you have a fairly old version of R (in particular pre 3.3.2 which is my version of R which is even older than 3.3.3 which is the 'oldrel' tested by Travis CI and CRAN) and if so which one?
- Does the error go away if you call
library("proto")
beforelibrary("argparse")
?
I suspect your error is because I recently moved the proto
package from the Depends field to the Imports field in the DESCRIPTION file and I think there is a bug in old versions of R where proto
doesn't import correctly as it should. I'm not sure which version exactly it was fixed but I guess I should add at least an R (>= 3.3.2) dependency in my DESCRIPTION since it seems to work for R versions at least that new.
I was able to reproduce your bug if I downgraded the dependency proto
from version 1.0.0 (released 2016-10-29) to the previous version (released 2012-12-22).
You should be able to get the newest version of argparse
working if you upgrade your version of proto
.
update.packages(oldPkgs = "proto")
Meanwhile I'll update the DESCRIPTION file to require proto (>= 1.0.0).
I've updated the DESCRIPTION file to explicitly require proto (>= 1.0.0).