Working with R types on Julia

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Working with R types on Julia

Diego Javier Zea
I was playing with littler. I'm saving the data to disk as RData. After this I'm reading it with read_rda() of DataFrames.jl

using DataFrames
function r(str::ASCIIString)
 name
= randstring(20) * ".RData"
 run
( ` r -e " $str ; save(list=ls()[ls()!=\"argv\"],file=\"$name\") " ` )
 data
= read_rda(name)
 run
(`rm $name`)
 data
end

But, I don't know how to use the data on Julia.

julia> data = r("a <- c(1:10); b <- c(2:11); c <- cor.test(a,b); d<-data.frame(a,b)")
Dict{ASCIIString,Any} with 4 entries:
 
"c" => RList({RNumeric([1.3421772799999999e8],["names"=>RString(ASCIIString["t"],Bool[false],Dict{ASCIIString,Any}())]),RInteger(Int32[8],["names"=>RString(ASCIIString["df"],Bool[false],Dict{ASCIIString,Any}()…
 
"b" => RInteger(Int32[2,3,4,5,6,7,8,9,10,11],Dict{ASCIIString,Any}())
 
"a" => RInteger(Int32[1,2,3,4,5,6,7,8,9,10],Dict{ASCIIString,Any}())
 
"d" => RList({RInteger(Int32[1,2,3,4,5,6,7,8,9,10],Dict{ASCIIString,Any}()),RInteger(Int32[2,3,4,5,6,7,8,9,10,11],Dict{ASCIIString,Any}())},["names"=>RString(ASCIIString["a","b"],Bool[false,false],Dict{ASCIISt


julia
> data["b"]
RInteger(Int32[2,3,4,5,6,7,8,9,10,11],Dict{ASCIIString,Any}())


julia
> data["b"][1]
ERROR
: `getindex` has no method matching getindex(::RInteger, ::Int64)


How can I get data from RList and RInteger types?
Best,

--
You received this message because you are subscribed to the Google Groups "julia-stats" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Working with R types on Julia

Diego Javier Zea
Ok, I need to use the data field :)

julia> b = data["b"]
RInteger(Int32[2,3,4,5,6,7,8,9,10,11],Dict{ASCIIString,Any}())


julia
> b.data

10-element Array{Int32,1}:
 
2
 
3
 
4
 
5
 
6
 
7
 
8
 
9
 
10
 
11




El viernes, 1 de agosto de 2014 03:42:26 UTC-3, Diego Javier Zea escribió:
I was playing with <a href="http://dirk.eddelbuettel.com/code/littler.html" style="font-weight:bold" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fdirk.eddelbuettel.com%2Fcode%2Flittler.html\46sa\75D\46sntz\0751\46usg\75AFQjCNHDk-GCqL6qUFOefXjUDnCTx3e21w';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fdirk.eddelbuettel.com%2Fcode%2Flittler.html\46sa\75D\46sntz\0751\46usg\75AFQjCNHDk-GCqL6qUFOefXjUDnCTx3e21w';return true;">littler. I'm saving the data to disk as RData. After this I'm reading it with read_rda() of DataFrames.jl

using DataFrames
function r(str::ASCIIString)
 name
= randstring(20) * ".RData"
 run
( ` r -e " $str ; save(list=ls()[ls()!=\"argv\"],file=\"$name\") " ` )
 data
= read_rda(name)
 run
(`rm $name`)
 data
end

But, I don't know how to use the data on Julia.

julia> data = r("a <- c(1:10); b <- c(2:11); c <- cor.test(a,b); d<-data.frame(a,b)")
Dict{ASCIIString,Any} with 4 entries:
 
"c" => RList({RNumeric([1.3421772799999999e8],["names"=>RString(ASCIIString["t"],Bool[false],Dict{ASCIIString,Any}())]),RInteger(Int32[8],["names"=>RString(ASCIIString["df"],Bool[false],Dict{ASCIIString,Any}()…
 
"b" => RInteger(Int32[2,3,4,5,6,7,8,9,10,11],Dict{ASCIIString,Any}())
 
"a" => RInteger(Int32[1,2,3,4,5,6,7,8,9,10],Dict{ASCIIString,Any}())
 
"d" => RList({RInteger(Int32[1,2,3,4,5,6,7,8,9,10],Dict{ASCIIString,Any}()),RInteger(Int32[2,3,4,5,6,7,8,9,10,11],Dict{ASCIIString,Any}())},["names"=>RString(ASCIIString["a","b"],Bool[false,false],Dict{ASCIISt


julia
> data["b"]
RInteger(Int32[2,3,4,5,6,7,8,9,10,11],Dict{ASCIIString,Any}())


julia
> data["b"][1]
ERROR
: `getindex` has no method matching getindex(::RInteger, ::Int64)


How can I get data from RList and RInteger types?
Best,

--
You received this message because you are subscribed to the Google Groups "julia-stats" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.