Swiftpack.co - Package - cran/cdata

The cdata package is a demonstration of the "coordinatized data" theory and includes an implementation of the "fluid data" methodology. The recommended tutorial is: Fluid data reshaping with cdata. We also have a short free cdata screencast (and another example can be found here).

Briefly: cdata supplies data transform operators that:

  • Work on local data or with any DBI data source.
  • Are powerful generalizations of the operators commonly called pivot and un-pivot.

A quick example:

# my_db <- DBI::dbConnect(RSQLite::SQLite(), 
#                         ":memory:")
my_db <- sparklyr::spark_connect(version='2.2.0', 
                                 master = "local")

# pivot example
d <- build_frame(
   "meas", "val" /
   "AUC" , 0.6   /
   "R2"  , 0.2   )
                  temporary = TRUE)
qlook(my_db, 'd')
## table `d` spark_connection spark_shell_connection DBIConnection 
##  nrow: 2 
## 'data.frame':    2 obs. of  2 variables:
##  $ meas: chr  "AUC" "R2"
##  $ val : num  0.6 0.2
cT <- build_pivot_control_q('d',
                              columnToTakeKeysFrom= 'meas',
                              columnToTakeValuesFrom= 'val',
                              my_db = my_db)
tab <- blocks_to_rowrecs_q('d',
                            keyColumns = NULL,
                            controlTable = cT,
                            my_db = my_db)
qlook(my_db, tab)
## table `mvtcq_66101738774069104522_0000000001` spark_connection spark_shell_connection DBIConnection 
##  nrow: 1 
## 'data.frame':    1 obs. of  2 variables:
##  $ AUC: num 0.6
##  $ R2 : num 0.2

Install via CRAN:


Or from GitHub using devtools:


Note: cdata is targeted at data with "tame column names" (column names that are valid both in databases, and as R unquoted variable names) and basic types (column values that are simple R types such as character, numeric, logical, and so on).


Stars: 0
Help us keep the lights on


Used By