augmentmaxT_f: Creates cell marginal max.

Description Usage Arguments Details Value Examples

View source: R/augmentT_f.R

Description

Creates cell marginal max.

Usage

1
augmentmaxT_f(.data, variables, verbose = getOption("verbose"))

Arguments

.data

a dataframe

variables

a vector of character strings

Details

Assume one runs the program

augmentmaxT_f(.dataBigSyn::STtableA1,variables=c("AA.present")). The program looks for all the "cell variables" corresponding to "AA.present", by using the function BigSyn::get_var

The results is this:

AA.present_La_La_Lrn1, AA.present_La_Lb_Lrn1, AA.present_La_Lc_Lrn1,

...

AA.present_Lc_La_Lrn4, AA.present_Lc_Lb_Lrn4, AA.present_Lc_Ld_Lrn4

The programs computes the number of marginal variables with the function BigSyn::get_cellXXmarginscount. Here it is 3

The program creates the following character matrix, named patterns:

"1" "La" ""

"1" "Lb" ""

"1" "Lc" ""

"2" "La_La" "La"

"2" "La_Ld" "La"

"2" "Lb_Lb" "Lb"

"2" "Lc_La" "Lc"

"2" "Lc_Lb" "Lc"

"2" "Lc_Ld" "Lc"

"2" "La_Lb" "La"

"2" "La_Lc" "La"

"2" "Lb_La" "Lb"

"2" "Lb_Lc" "Lb"

"2" "Lb_Ld" "Lb"

"2" "Lc_Lc" "Lc"

"3" "La_La_Lrn1" "La_La"

"3" "La_Ld_Lrn1" "La_Ld"

"3" "Lb_Lb_Lrn1" "Lb_Lb"

"3" "Lc_La_Lrn1" "Lc_La"

"3" "Lc_Lb_Lrn1" "Lc_Lb"

"3" "Lc_Ld_Lrn1" "Lc_Ld"

"3" "La_Lb_Lrn1" "La_Lb"

"3" "La_Lc_Lrn1" "La_Lc"

"3" "Lb_La_Lrn1" "Lb_La"

"3" "Lb_Lc_Lrn1" "Lb_Lc"

"3" "Lb_Ld_Lrn1" "Lb_Ld"

"3" "Lc_Lc_Lrn1" "Lc_Lc"

"3" "La_La_Lrn2" "La_La"

"3" "La_Ld_Lrn2" "La_Ld"

"3" "Lb_Lb_Lrn2" "Lb_Lb"

"3" "Lc_La_Lrn2" "Lc_La"

"3" "Lc_Lb_Lrn2" "Lc_Lb"

"3" "Lc_Ld_Lrn2" "Lc_Ld"

"3" "La_Lb_Lrn2" "La_Lb"

"3" "La_Lc_Lrn2" "La_Lc"

"3" "Lb_La_Lrn2" "Lb_La"

"3" "Lb_Lc_Lrn2" "Lb_Lc"

"3" "Lb_Ld_Lrn2" "Lb_Ld"

"3" "Lc_Lc_Lrn2" "Lc_Lc"

"3" "La_La_Lrn3" "La_La"

"3" "La_Ld_Lrn3" "La_Ld"

"3" "Lb_Lb_Lrn3" "Lb_Lb"

"3" "Lc_La_Lrn3" "Lc_La"

"3" "Lc_Lb_Lrn3" "Lc_Lb"

"3" "Lc_Ld_Lrn3" "Lc_Ld"

"3" "La_Lb_Lrn3" "La_Lb"

"3" "La_Lc_Lrn3" "La_Lc"

"3" "Lb_La_Lrn3" "Lb_La"

"3" "Lb_Lc_Lrn3" "Lb_Lc"

"3" "Lb_Ld_Lrn3" "Lb_Ld"

"3" "Lc_Lc_Lrn3" "Lc_Lc"

"3" "La_La_Lrn4" "La_La"

"3" "La_Ld_Lrn4" "La_Ld"

"3" "Lb_Lb_Lrn4" "Lb_Lb"

"3" "Lc_La_Lrn4" "Lc_La"

"3" "Lc_Lb_Lrn4" "Lc_Lb"

"3" "Lc_Ld_Lrn4" "Lc_Ld"

Then for all i in 3:1 (starting with the maximum depth) list the different aggregations to the upper level to perform. So for i=3, aggregating to the second level will be done by computing the variables :

AA.cont1_La_La, AA.cont1_La_Ld, AA.cont1_Lb_Lb, AA.cont1_Lc_La,

AA.cont1_Lc_Lb, AA.cont1_Lc_Ld, AA.cont1_La_Lb, AA.cont1_La_Lc,

AA.cont1_Lb_La, AA.cont1_Lb_Lc, AA.cont1_Lb_Ld, AA.cont1_Lc_Lc

For example:

AA.cont1_La_La =rowSums(.data([,c("AA.cont1_La_La_Lrn1", "AA.cont1_La_La_Lrn2", "AA.cont1_La_La_Lrn3", "AA.cont1_La_La_Lrn4"),drop=FALSE])

For i=2 aggregating to the upper level will be done by computing the variables :

AA.cont1_La, AA.cont1_Lb, AA.cont1_Lc

AA.cont1_La =rowSums(.data([,c("AA.cont1_La_La", "AA.cont1_La_Ld", "AA.cont1_La_Lb", "AA.cont1_La_Lc"),drop=FALSE])

For i=1 aggregating to theupper level will be done by computng the variable:

AA.cont1_=rowSums(.data([,c("AA.cont1_La", "AA.cont1_Lb", "AA.cont1_Lc"),drop=FALSE])

The computation of the marginal totals is done, the second step is the computation of the marginal ratios.

It is done by looping on the rows of the patterns matrix

Line j of pattern is a length 3 character vector. let call patterns[j,2] x and patterns[j,3] y The programs replaces the variable names paste0("AA.cont1",x) by the ration of the variable paste0("AA.cont1",x) by the variable named paste0("AA.cont1",y).

For example for the line "3" "La_Ld_Lrn3" "La_Ld", the following replacement will be made: AA.cont1_La_Ld_Lrn3=AA.cont1_La_Ld_Lrn3/AA.cont1_La_Ld

The same is applied to all the elements of the input parameter variables.

Value

a dataframe.

Examples

1
2
3
4
5
6
7
8
.data=BigSyn::STtableA1
variable="AA.present"
variables=variable
ASTtableA1<-augmentmaxT_f(.data,variables)
ASTtableA1[1:5,c("AA.present_","AA.present_La","AA.present_La_Lb")]
xx<-ASTtableA1[sort(grep("present",names(ASTtableA1),value=TRUE))]
xx[xx==0]<-NA
StudyDataTools::ggplot_missing(xx)

DanielBonnery/BigSyn documentation built on June 28, 2020, 7:18 p.m.