I'm afraid the Rif.R("names<-") is not working.
julia> Rif.initr()
Using R_HOME=/home/Mine/programs/Rstat/R-3.1.1
0
julia> Rif.R("names<-")
ERROR: R is not initialized
in parseR at /home/JXiong/.julia/v0.4/Rif/src/Rif.jl:251
in R at /home/JXiong/.julia/v0.4/Rif/src/Rif.jl:277
On Sunday, October 26, 2014 11:01:51 PM UTC+1, lgautier wrote:
>
> Currently the way to do is to explicitly call the R-level setter:
>
> x = Rif.R("names<-")(x, Rif.cR("A", "B", "C"))
>
>
> However, as of today commit the C-level is exposed and a way that is
> looking a little more like native Julia.
> (I'll do a pull request so this is part of the released package soon).
>
> The unit-tests are for vectors, and should be explict:
> https://github.com/lgautier/Rif.jl/blob/master/test/vectors.jl#L57
>
> ```julia
> # The C API for R has specialized MACRO for names getrnames/setrnames
> # exposes it
> vi2 = Int32[1,2,3]
> rvi2 = Rif.RArray{Int32,1}(vi2)
> @test isequal(None, Rif.getrnames(rvi2))
> Rif.setrnames!(rvi2, Rif.RArray{ASCIIString,1}(ASCIIString["a", "b", "c"]))
> @test isequal("a", Rif.getrnames(rvi2)[1])
> @test isequal("b", Rif.getrnames(rvi2)[2])
> @test isequal("c", Rif.getrnames(rvi2)[3])
>
> # setAttr/getAttr will be equivalent
> vi2 = Int32[1,2,3]
> rvi2 = Rif.RArray{Int32,1}(vi2)
> @test_throws ErrorException Rif.getAttr(rvi2, "names")
> Rif.setAttr!(rvi2, "names",
> Rif.RArray{ASCIIString,1}(ASCIIString["a", "b", "c"]))
> @test isequal("a", Rif.getAttr(rvi2, "names")[1])
> @test isequal("a", Rif.getrnames(rvi2)[1])
> @test isequal("b", Rif.getAttr(rvi2, "names")[2])
> @test isequal("b", Rif.getrnames(rvi2)[2])
> @test isequal("c", Rif.getAttr(rvi2, "names")[3])
> @test isequal("c", Rif.getrnames(rvi2)[3])
> ```
>
> On Saturday, October 25, 2014 12:38:10 PM UTC-4, [email protected] wrote:
>>
>> In R, we can assign names for a variable as:
>> > x<-c(1,2,3)
>> > names(x)=c("A","B","C")
>> > x
>> A B C
>> 1 2 3
>>
>> In Julia, I can create a RArray by
>> x=Rif.cR([1,2,3])
>> But anyone know how to assign the "names" to this RArray variable in
>> Julia?
>>
>