RData.jl

Coverage StatusBuild StatusBuild status

Read R data files (.rda, .RData) and optionally convert the contents into Julia equivalents.

Can read any R data archive, although not all R types could be converted into Julia.

For running R code from Julia see RCall.jl.

Installation

From Julia REPL:

Pkg.add("RData")

Compression formats

R data files could be compressed by either Gzip (the default), Bzip2 or Xz methods. RData.jl supports Gzip-compressed files out-of-the-box. To read Bzip2 or Xz-compressed files CodecBzip2.jl or CodecXz.jl must be installed.

For example, to load a file compressed by Bzip2 you must first install the required codec:

Pkg.add("CodecBzip2")

Then ensure CodecBzip2 is loaded before calling RData.load:

using RData
import CodecBzip2

load('some_bzip2_compressed.rda')

Usage

To read R objects from "example.rda" file:

using RData

objs = load("path_to/example.rda")

The result is a dictionary (Dict{String, Any}) of all R objects stored in "example.rda".

If convert=true keyword option is specified, load() will try to automatically convert R objects into Julia equivalents:

R objectJulia object
named vector, listDictoVecDictoVec allows indexing both by element index and by its name, just as R vectors and lists
vectorVector{T}T is the appropriate Julia type. If R vector contains NA values, they are converted to missing, and the elements type of the resulting Vector is Union{T, Missing}.
factorCategoricalArrayCategoricalArrays.jl
DateDates.Date
POSIXct date timeZonedDateTimeTimeZones.jl
data frameDataFrameDataFrames.jl

If conversion to the Julia type is not supported (e.g. R closure or language expression), load() will return the internal RData representation of the object (RSEXPREC subtype).