Learn R Programming

JuliaConnectoR (version 1.1.0)

as.data.frame.JuliaProxy: Coerce a Julia Table to a Data Frame

Description

Get the data from a Julia proxy object that implements the Julia Tables interface, and create an R data frame from it.

Usage

# S3 method for JuliaProxy
as.data.frame(x, ...)

Arguments

x

a proxy object pointing to a Julia object that implements the interface of the package Julia package Tables

...

(not used)

Details

Strings are not converted to factors.

Examples

Run this code
# NOT RUN {
if (juliaSetupOk()) {

   # Demonstrate the usage with the Julia package "IndexedTables" (v1.0)

   # Install the package first if it is not installed:
   # juliaEval('import Pkg; Pkg.add("IndexedTables")')

   # Import "IndexedTables" package
   IndexedTables <- juliaImport("IndexedTables")

   mydf <- data.frame(x = c(1, 2, 3),
                      y = c("a", "b", "c"),
                      z = c(TRUE, FALSE, NA),
                      stringsAsFactors = FALSE)

   # Create a table in Julia, e. g. via IndexedTables
   mytbl <- IndexedTables$table(mydf)

   # This table can, e g. be queried and
   # the result can be translated to an R data frame.
   seltbl <- IndexedTables$select(mytbl, juliaExpr("(:x, :y)"))[1:2]

   # Translate selection of Julia table into R data frame
   as.data.frame(seltbl)

}

# }

Run the code above in your browser using DataLab