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

REvalError when trying to access function arguments #401

Closed
kskyten opened this issue Nov 21, 2020 · 2 comments
Closed

REvalError when trying to access function arguments #401

kskyten opened this issue Nov 21, 2020 · 2 comments

Comments

@kskyten
Copy link

kskyten commented Nov 21, 2020

I'm trying to convert R code to Julia and ran into the following problem while trying to extract the arguments from a function expression:

julia> using RCall

julia> rparse("function(x){x + 2}")[1][2][1]
RObject{RCall.SymSxp}
Error showing value of type RObject{RCall.SymSxp}:
ERROR: REvalError: Error in function (x, digits = NULL, quote = TRUE, na.print = NULL, print.gap = NULL,  :
  argument "x" is missing, with no default

How do I extract the function argument x as a symbol?

@kskyten
Copy link
Author

kskyten commented Nov 21, 2020

It seems function arguments are stored as pairlists. To get the names of the elements in R you can use names(args). Is there a way to call names from Julia on the pairlist object? It has type RObject{LangSxp}.

@kskyten
Copy link
Author

kskyten commented Nov 21, 2020

It is just RCall.names(args).

@kskyten kskyten closed this as completed Nov 21, 2020
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

1 participant