R mapping

rqdatatable re-maps a number of symbols for data.table translation (for rquery/SQL re-mappings, please see here). For instance, please take note of the n() and rank() functions in the following code example.

library("rqdatatable")
library("wrapr")

dL <- build_frame(
  "subjectID", "surveyCategory"     , "assessmentTotal"|
    1          , "withdrawal behavior", 5              |
    1          , "positive re-framing", 2              |
    2          , "withdrawal behavior", 3              |
    2          , "positive re-framing", 4              |
    2          , "other"              , 0              )

scale <- 0.237
rquery_pipeline <- local_td(dL) %.>%
  extend_nse(.,
             probability :=
               exp(assessmentTotal * scale)/
               sum(exp(assessmentTotal * scale)),
             count := n(),
             rank := rank(),
             orderby = c("assessmentTotal", "surveyCategory"),
             reverse = c("assessmentTotal"),
             partitionby = 'subjectID')  %.>%
  orderby(., c("subjectID", "probability"))
res <- ex_data_table(rquery_pipeline, tables = list(dL = dL))
knitr::kable(res)

The common re-mappings are can be found in the package-private variable rqdatatable:::data_table_extend_fns.

str(rqdatatable:::data_table_extend_fns)

The column rqdatatable_temp_one_col is introduced (and removed) from intermediate data frames as needed.

These mappings help allow the same operator pipeline to be used in R and in a database. For the database mappings please see here.



Try the rqdatatable package in your browser

Any scripts or data that you put into this service are public.

rqdatatable documentation built on Jan. 23, 2022, 1:06 a.m.