compose: add layer to current composition

Description Usage Arguments Value Examples

Description

add layer to current composition

Usage

1
2
3
4
5
6
7
compose(.data, source, to, where.selected.any = NULL,
  where.selected.all = NULL, where.selected.exactly = NULL,
  where.selected.none = NULL, where.num.equal = NULL,
  where.num.smaller = NULL, where.num.smaller.equal = NULL,
  where.num.larger = NULL, where.num.larger.equal = NULL,
  where.string = NULL, otherwise.to = NA, skipped.to = NA,
  na.to = NA, questionnaire = NULL)

Arguments

.data

the composition, see new_composition()

source

the name of the source variable to compose from

to

the value to set the new composition to if the condition is fulfilled

where.selected..

: a vector of choices; setting values to 'to' where in the source variable any/all/exactly/none of the supplied choices had been selected

where.num...

: a scalar number. setting values to 'to' where the 'source' is equal / smaller / smaller or equal / larger / larger or euqal than the number supplied in where.num...

otherwise

an alternative value to be used if the condition is not fulfilled, the source is not NA and not skipped

Value

the updated composition

Examples

1
2
3
4
5
6
7
df<-data.frame(a=1:100,b=sample(letters[1:5],100,T))

df %>% new_composition("new_variable_name") %>%
compose("a",to = "less than 50" ,where.num.smaller = 50) %>%
compose("a",to = "more or equal 50", where.num.larger.equal = 50)
compose("b",to = "(size not important)",where.selected.exactly = "d") %>%
end_composition()

mabafaba/composr documentation built on June 10, 2019, 8:17 a.m.