recode_to_pmml: Creates a PMML document from variable and variable details...

Description Usage Arguments Value Examples

View source: R/pmml.R

Description

Creates a PMML document from variable and variable details sheets for specified database.

Usage

1
recode_to_pmml(var_details_sheet, vars_sheet, db_name, vars_to_convert = NULL)

Arguments

var_details_sheet

A data frame representing a variable details sheet.

vars_sheet

A data frame representing a variables sheet.

db_name

A string containing the name of the database that holds the start variables. Should match up with one of the databases in the databaseStart column.

vars_to_convert

A vector of strings containing the names of variables from the variable column in the variable details sheet that should be converted to PMML. Passing in an empty vector will convert all the variables.

Value

A PMML document.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
var_details_sheet <-
data.frame(
 "variable" = rep(c("A", "B", "C"), each = 3),
 "dummyVariable" = c("AY", "AN", "ANA", "BY", "BN", "BNA", "CY", "CN", "CNA"),
 "toType" = rep("cat", times = 9),
 "databaseStart" = rep("tester", times = 9),
 "variableStart" = rep(
   c("tester::startA", "tester::startB", "tester::startC"),
   each = 3
 ),
 "fromType" = rep("cat", times = 9),
 "recTo" = rep(c("1", "2", "NA::a"), times = 3),
 "numValidCat" = rep("2", times = 9),
 "catLabel" = rep(c("Yes", "No", "Not answered"), times = 3),
 "catLabelLong" = rep(c("Yes", "No", "Not answered"), times =
                        3),
 "recFrom" = rep(c("1", "2", "9"), times = 3),
 "catStartLabel" = rep(c("Yes", "No", "Not answered"), times =
                         3),
 "variableStartShortLabel" = rep(c("Group A", "Group B", "Group C"), each =
                                   3),
 "variableStartLabel" = rep(c("Group A", "Group B", "Group C"), each =
                              3),
 "units" = rep("NA", times = 9),
 "notes" = rep("This is not real data", times = 9)
)
vars_sheet <-
 data.frame(
   "variable" = c("A", "B", "C"),
   "label" = c("Group A", "Group B", "Group C"),
   "labelLong" = c("Group A", "Group B", "Group C"),
   "section" = rep("tester", times=3),
   "subject" = rep("tester",times = 3),
   "variableType" = rep("Categorical", times=3),
   "databaseStart" = rep("tester", times = 3),
   "units" = rep("NA", times = 3),
   "variableStart" = c("tester::startA", "tester::startB", "tester::startC")
 )
db_name <- "tester"
vars <- c("A", "B", "C")

actual_pmml <- recode_to_pmml(
var_details_sheet,
vars_sheet,
db_name,
vars
)

recodeflow documentation built on June 9, 2021, 9:07 a.m.