createDefMeasures {rrMisc}R Documentation

Create input table for descriptive table generated by descrTable

Description

Create input table for descriptive table generated by descrTable. This input table defines the variables to report, the measures to apply and the precision of the results.

Usage

createDefMeasures(d.data, var.list)

Arguments

d.data

Data frame to report statistics from

var.list

A data frame for the mapping of the variable names to meaningful labels. The attribute 'var_name' for the variable names in d.data and 'var_label' for the labels.

Details

utility function for formating

Value

data.frame as input for 'descrTable'

- measure_label: label text shown in resulting table (output from descrTable())

- measure_name: variable name

- measure_1: first statistics to be applied to date

- measure_2: second statistics to be applied to date

- measure_ref_level: for factors, specify the reference level

- measure_prec_1: precision - number of decimal places - for first statistics

- measure_prec_2: precision for second statistics

Note

under continuous developement

Author(s)

Roland Rapold

References

none

See Also

other utility-functions in this R-package

Examples

if(require("car")) {
    # load sample data 'Mroz' from package 'car'
    data(Mroz)
    str(Mroz)

    # insert attribute 'i' for population size
    Mroz <- merge(data.frame(i=as.factor(1)), Mroz)
    str(Mroz)

    # reference list for variable labels
    var.list <- data.frame(var_name=c("i", "lfp", "k5", "k618", "wc", "lwg", "inc"),
                           var_label=c("population",
                                       "employed",
                                       "# children to 5", "# children 6-18",
                                       "wife college",
                                       "log expected wage",
                                       "family income excl. wife"))

    # create definition-table without variable for groups
    Mroz_hc      <- Mroz[ , -which(colnames(Mroz)=="hc")]

    # variation 1: default, no adjustments
    def.measures.1 <- createDefMeasures(d.data=Mroz_hc)
    print(def.measures.1)

    # variation 2: apply variable labels
    def.measures.2 <- createDefMeasures(d.data=Mroz_hc, var.list=var.list)
    def.measures.2[2, 6] <- -2
    def.measures.2[9, 6] <- -1
    print(def.measures.2)

}

[Package rrMisc version 0.31 Index]