ec.Recode: DataFrame Tools : Recode the content of a column

Description Usage Arguments Details Value Author(s) Examples

Description

Recode the content of a column (variable) of GDS. GDS is the Global DataSet.

Usage

1
ec.Recode(x, where, by, gen = "")

Arguments

x

- a string value, the name of the column to be recoded

where

- a list of logical expressions

by

- a list of values matching the list of logical expressions. Originals values will be replaced by these

gen

- optional string, the name of the new column

Details

TODO

Value

Return nothing. GDS the Global DataSet is modified

Author(s)

jp.decorps@epiconcept.fr

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# -----------------------------------------------------------
# Recode the 'carb' column with 0 if carb is lower than 3
# and with 1 if 'carb' higher or equal than 3
# -----------------------------------------------------------
data(mtcars)
ec.Use(mtcars);
str(GDS)
ec.Recode("carb", where = list(VAL("carb") < 3, VAL("carb") >= 3), by=list(0,1))
str(GDS)

# -----------------------------------------------------------
# Create a new column (variable) named 'carGroup' which contains the
# recoding of the 'carb' column. The 'carb' column is not modified.
# -----------------------------------------------------------
data(mtcars)
ec.Use(mtcars);
str(GDS)
ec.Recode("carb", where = list(VAL("carb") < 3, VAL("carb") >= 3), by=list(0,1), gen="carbGroup")
str(GDS)

Epiconcept-Paris/Epiconcepts documentation built on May 6, 2019, 3:49 p.m.