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

Find the number of arguments for an RFunction? #503

Closed
ChrisRackauckas opened this issue Oct 7, 2023 · 1 comment
Closed

Find the number of arguments for an RFunction? #503

ChrisRackauckas opened this issue Oct 7, 2023 · 1 comment

Comments

@ChrisRackauckas
Copy link
Member

If I have an RFunction from R, is there a way to know how many arguments it expects?

ChrisRackauckas added a commit to SciML/SciMLBase.jl that referenced this issue Oct 7, 2023
Fixes the name of the extensions so they don't clash elsewhere. Also adds an RCall one which is basic and assumes out of place, which is a fine assumption given that R is copy-on-write and thus mutation of the form of an in-place function is just not possible. This means that we don't get the great error messages, but oh well we can figure that out later.

Fixes SciML/diffeqr#41

Better version requires JuliaInterop/RCall.jl#503
@simonbyrne
Copy link
Member

You can use formals:

julia> f = R"function(a,b=2) a+b"
RObject{ClosSxp}
function (a, b = 2)
a + b


julia> R"formals"(f)
RObject{ListSxp}
$a


$b
[1] 2


julia> length(R"formals"(f))
2

@palday palday closed this as completed Nov 14, 2023
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

3 participants