change_form: change_form

Description Usage Arguments Value Author(s) See Also Examples

Description

Transform a data from one form into another.

Usage

1
2
change_form(dat, from, to,
            old_response, category, new_response)

Arguments

dat

A data whose features are categorical and response(s) is/are nonnegative integer vector(s).

from

A character; either 'binary', 'binomial', or 'poisson'

to

A character != from; either 'binary', 'binomial', or 'poisson'

old_response

(always specified) a character vector of:

  • length 1 if from = 'binary' or 'poisson'; the name of column in dat that stores a response/count.

  • lenght 2 if from = 'binomial'; the names of columns in dat that store positive and negative case counts, in this order.

category

(specified if either to = 'poisson' or (from, to) = ('poisson', 'binomial')) a character vector of:

  • length 1 if from = 'binomial' OR (from, to) = ('poisson', 'binomial'); the new name of column that will store two names in old_response as positive and negative cases, in this order; OR, the column in dat that is used as a binary response in case of logistic regression if (from, to) = ('poisson', 'binomial').

  • length 2 if from = 'binary'; the new names for positive and negative cases in the binary response column, in this order.

new_response

(specified only if from != 'poisson') a character vector of:

  • length 1 if to = 'binary' or 'poisson'; the name of the new column in new data that will store either a binary or count response.

  • length 2 if to = 'binomial'; the names of two columns in new data that will store positive and negative case counts, in this order.

Value

A data.table that has transformed from the form specified in from to the form specified in to.

Author(s)

Junkyu Park

See Also

binarize_binom, binarize_pois, Binarizing data using data.table

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
change_form(
    rich,
    from = 'binary', to = 'binomial',
    old_response = 'is_rich',
    new_response = c('rich', 'not_rich')
)
change_form(
    rich,
    from = 'binary', to = 'poisson',
    old_response = 'is_rich',
    category = c('rich', 'not_rich'),
    new_response = 'count'
)
change_form(
    rich_binom,
    from = 'binomial', to = 'binary',
    old_response = c('rich', 'not_rich'),
    new_response = 'is_rich'
)
change_form(
    rich_binom,
    from = 'binomial', to = 'poisson',
    old_response = c('rich', 'not_rich'),
    category = 'is_rich',
    new_response = 'count'
)
change_form(
    rich_pois,
    from = 'poisson', to = 'binary',
    old_response = 'count'
)
change_form(
    rich_pois,
    from = 'poisson', to = 'binomial',
    old_response = 'count',
    category = 'is_rich'
)

joon3216/funpark documentation built on June 18, 2019, 7:32 a.m.