You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem is that R doesn't have scalars: "scalars" are just 1-element vectors. I made the judgement call here to have 1-element vectors copied as scalars, since that is presumably what most people would find useful.
Note that in R an "array" is a multidimensional structure, i.e. a vector is not an array by default:
> is.array(c(1,2,3))
[1] FALSE
If you want rcopy to return a specific type out, you can specify it as the first argument, e.g. rcopy(Vector, a).
Thanks for your explanation. I think rcopy(Vector, ...) is a useful design since the output type is always expected. Maybe this syntax can be officially documented.
Alternatively, I may propose to add a flag in rcopy, like
rcopy(R"1", drop=true) = 1.0 (default)
rcopy(R"1", drop=false) = Vector[1.0]
rcopy(R"matrix(1)", drop=false) = Matrix[1.0]
rcopy(R"array(1)", drop=false) = Array{Float64, N}[1.0]
@simonbyrne This seems like a good issue to pin and close so that users see it right away when they come to ask what's going wrong with 1-element vectors. 😄
One feature in the RCall confused me.
Although both print the same "1", R considered them as different data types:
However, rcopy(...) returns the same value 1:
I think rcopy(a)=[ 1.0 ] could be more reasonable. Is there any reason why regard array(1) as 1?
The text was updated successfully, but these errors were encountered: