Splits a (numeric/logical/character) vector, matrix, data.frame or a list of such into a list of columns, with corresponding group and variable information as well as labels. This is an auxiliary function for checking and converting the data argument of zenplot().

burst(x, labs = list())

Arguments

x

A numeric vector, matrix, data.frame or, for burst(), a list of such.

labs

Either NULL (in which case neither group nor variable labels are used or computed) or a list with components

group - the group label basename or labels for the groups (or NULL for no group labels)

var - the variable label basename or labels for the variables (or NULL for no variable labels)

sep - the string used as the separator between group and variable labels

group2d - a logical indicating whether labels of group_2d_*() plots are affected by group = NULL (or printed anyway)

If any of these components is not given, it is set to the defaults as described in zenplot(). Note that if at least one (group or variable) label is given in x, then those (original) labels will be used. If labs = NULL, neither group nor variable labels are used.

Value

A list with components

xcols - a list containing the column vectors of x

groups - the group number for each column of x

vars - the variable number (within each group) for each column of x

glabs - the group label for each column of x

labs - the group and variable labels for each column of x

Note

Performance critical

See also

Other tools for constructing your own plot1d and plot2d functions: burst_aux(), check_zargs(), extract_1d(), extract_2d(), plot_indices()

Author

Marius Hofert

Examples

## Unnamed list of (some named, some unnamed) valid components
A <- matrix(1:12, ncol = 3)
x <- list(A, 1:4, as.data.frame(A))

burst(x, labs = list(group = "G", var = "V", sep = ", "))
#> $xcols
#> $xcols$`G1, V1`
#> [1] 1 2 3 4
#> 
#> $xcols$`G1, V2`
#> [1] 5 6 7 8
#> 
#> $xcols$`G1, V3`
#> [1]  9 10 11 12
#> 
#> $xcols$`G2, V1`
#> [1] 1 2 3 4
#> 
#> $xcols$`G3, V1`
#> [1] 1 2 3 4
#> 
#> $xcols$`G3, V2`
#> [1] 5 6 7 8
#> 
#> $xcols$`G3, V3`
#> [1]  9 10 11 12
#> 
#> 
#> $groups
#> [1] 1 1 1 2 3 3 3
#> 
#> $vars
#> [1] 1 2 3 1 1 2 3
#> 
#> $glabs
#> [1] "G1" "G1" "G1" "G2" "G3" "G3" "G3"
#> 
#> $vlabs
#> [1] "V1" "V2" "V3" "V1" "V1" "V2" "V3"
#> 
burst(x) # the same defaults as above
#> $xcols
#> $xcols$`G1, V1`
#> [1] 1 2 3 4
#> 
#> $xcols$`G1, V2`
#> [1] 5 6 7 8
#> 
#> $xcols$`G1, V3`
#> [1]  9 10 11 12
#> 
#> $xcols$`G2, V1`
#> [1] 1 2 3 4
#> 
#> $xcols$`G3, V1`
#> [1] 1 2 3 4
#> 
#> $xcols$`G3, V2`
#> [1] 5 6 7 8
#> 
#> $xcols$`G3, V3`
#> [1]  9 10 11 12
#> 
#> 
#> $groups
#> [1] 1 1 1 2 3 3 3
#> 
#> $vars
#> [1] 1 2 3 1 1 2 3
#> 
#> $glabs
#> [1] "G1" "G1" "G1" "G2" "G3" "G3" "G3"
#> 
#> $vlabs
#> [1] "V1" "V2" "V3" "V1" "V1" "V2" "V3"
#> 
burst(x, labs = list(sep = " ")) # only changing the separator
#> $xcols
#> $xcols$`G1 V1`
#> [1] 1 2 3 4
#> 
#> $xcols$`G1 V2`
#> [1] 5 6 7 8
#> 
#> $xcols$`G1 V3`
#> [1]  9 10 11 12
#> 
#> $xcols$`G2 V1`
#> [1] 1 2 3 4
#> 
#> $xcols$`G3 V1`
#> [1] 1 2 3 4
#> 
#> $xcols$`G3 V2`
#> [1] 5 6 7 8
#> 
#> $xcols$`G3 V3`
#> [1]  9 10 11 12
#> 
#> 
#> $groups
#> [1] 1 1 1 2 3 3 3
#> 
#> $vars
#> [1] 1 2 3 1 1 2 3
#> 
#> $glabs
#> [1] "G1" "G1" "G1" "G2" "G3" "G3" "G3"
#> 
#> $vlabs
#> [1] "V1" "V2" "V3" "V1" "V1" "V2" "V3"
#> 
## Note: - No group labels are given in 'x' and thus they are constructed
##         in the above call
##        - The variable names are only constructed if not given

burst(x, labs = list(group = ""))
#> $xcols
#> $xcols$`1, V1`
#> [1] 1 2 3 4
#> 
#> $xcols$`1, V2`
#> [1] 5 6 7 8
#> 
#> $xcols$`1, V3`
#> [1]  9 10 11 12
#> 
#> $xcols$`2, V1`
#> [1] 1 2 3 4
#> 
#> $xcols$`3, V1`
#> [1] 1 2 3 4
#> 
#> $xcols$`3, V2`
#> [1] 5 6 7 8
#> 
#> $xcols$`3, V3`
#> [1]  9 10 11 12
#> 
#> 
#> $groups
#> [1] 1 1 1 2 3 3 3
#> 
#> $vars
#> [1] 1 2 3 1 1 2 3
#> 
#> $glabs
#> [1] "1" "1" "1" "2" "3" "3" "3"
#> 
#> $vlabs
#> [1] "V1" "V2" "V3" "V1" "V1" "V2" "V3"
#> 
burst(x, labs = list(group = NULL, group2d = TRUE)) # no group labels
#> $xcols
#> $xcols$V1
#> [1] 1 2 3 4
#> 
#> $xcols$V2
#> [1] 5 6 7 8
#> 
#> $xcols$V3
#> [1]  9 10 11 12
#> 
#> $xcols$V1
#> [1] 1 2 3 4
#> 
#> $xcols$V1
#> [1] 1 2 3 4
#> 
#> $xcols$V2
#> [1] 5 6 7 8
#> 
#> $xcols$V3
#> [1]  9 10 11 12
#> 
#> 
#> $groups
#> [1] 1 1 1 2 3 3 3
#> 
#> $vars
#> [1] 1 2 3 1 1 2 3
#> 
#> $glabs
#> [1] "" "" "" "" "" "" ""
#> 
#> $vlabs
#> [1] "V1" "V2" "V3" "V1" "V1" "V2" "V3"
#> 
##  Note: There's no effect of 'group2d = TRUE' visible here as
##        'x' doesn't contain group labels

burst(x, labs = list(group = NULL)) # no group labels unless groups change
#> $xcols
#> $xcols$V1
#> [1] 1 2 3 4
#> 
#> $xcols$V2
#> [1] 5 6 7 8
#> 
#> $xcols$V3
#> [1]  9 10 11 12
#> 
#> $xcols$V1
#> [1] 1 2 3 4
#> 
#> $xcols$V1
#> [1] 1 2 3 4
#> 
#> $xcols$V2
#> [1] 5 6 7 8
#> 
#> $xcols$V3
#> [1]  9 10 11 12
#> 
#> 
#> $groups
#> [1] 1 1 1 2 3 3 3
#> 
#> $vars
#> [1] 1 2 3 1 1 2 3
#> 
#> $glabs
#> NULL
#> 
#> $vlabs
#> [1] "V1" "V2" "V3" "V1" "V1" "V2" "V3"
#> 
burst(x, labs = list(var = NULL)) # no variable labels
#> $xcols
#> $xcols$G1
#> [1] 1 2 3 4
#> 
#> $xcols$G1
#> [1] 5 6 7 8
#> 
#> $xcols$G1
#> [1]  9 10 11 12
#> 
#> $xcols$G2
#> [1] 1 2 3 4
#> 
#> $xcols$G3
#> [1] 1 2 3 4
#> 
#> $xcols$G3
#> [1] 5 6 7 8
#> 
#> $xcols$G3
#> [1]  9 10 11 12
#> 
#> 
#> $groups
#> [1] 1 1 1 2 3 3 3
#> 
#> $vars
#> [1] 1 2 3 1 1 2 3
#> 
#> $glabs
#> [1] "G1" "G1" "G1" "G2" "G3" "G3" "G3"
#> 
#> $vlabs
#> [1] "" "" "" "" "" "" ""
#> 
burst(x, labs = list(group = NULL, var = NULL)) # neither one
#> $xcols
#> $xcols[[1]]
#> [1] 1 2 3 4
#> 
#> $xcols[[2]]
#> [1] 5 6 7 8
#> 
#> $xcols[[3]]
#> [1]  9 10 11 12
#> 
#> $xcols[[4]]
#> [1] 1 2 3 4
#> 
#> $xcols[[5]]
#> [1] 1 2 3 4
#> 
#> $xcols[[6]]
#> [1] 5 6 7 8
#> 
#> $xcols[[7]]
#> [1]  9 10 11 12
#> 
#> 
#> $groups
#> [1] 1 1 1 2 3 3 3
#> 
#> $vars
#> [1] 1 2 3 1 1 2 3
#> 
#> $glabs
#> NULL
#> 
#> $vlabs
#> [1] "" "" "" "" "" "" ""
#> 
burst(x, labs = NULL) # similarly, without any labels at all
#> $xcols
#> $xcols[[1]]
#> [1] 1 2 3 4
#> 
#> $xcols[[2]]
#> [1] 5 6 7 8
#> 
#> $xcols[[3]]
#> [1]  9 10 11 12
#> 
#> $xcols[[4]]
#> [1] 1 2 3 4
#> 
#> $xcols[[5]]
#> [1] 1 2 3 4
#> 
#> $xcols[[6]]
#> [1] 5 6 7 8
#> 
#> $xcols[[7]]
#> [1]  9 10 11 12
#> 
#> 
#> $groups
#> [1] 1 1 1 2 3 3 3
#> 
#> $vars
#> [1] 1 2 3 1 1 2 3
#> 
#> $glabs
#> NULL
#> 
#> $vlabs
#> NULL
#> 

##  Named list
x <- list(mat = A, vec = 1:4, df = as.data.frame(A))
burst(x)
#> $xcols
#> $xcols$`mat, V1`
#> [1] 1 2 3 4
#> 
#> $xcols$`mat, V2`
#> [1] 5 6 7 8
#> 
#> $xcols$`mat, V3`
#> [1]  9 10 11 12
#> 
#> $xcols$`vec, V1`
#> [1] 1 2 3 4
#> 
#> $xcols$`df, V1`
#> [1] 1 2 3 4
#> 
#> $xcols$`df, V2`
#> [1] 5 6 7 8
#> 
#> $xcols$`df, V3`
#> [1]  9 10 11 12
#> 
#> 
#> $groups
#> [1] 1 1 1 2 3 3 3
#> 
#> $vars
#> [1] 1 2 3 1 1 2 3
#> 
#> $glabs
#> [1] "mat" "mat" "mat" "vec" "df"  "df"  "df" 
#> 
#> $vlabs
#> [1] "V1" "V2" "V3" "V1" "V1" "V2" "V3"
#> 
##  Note: - The given group labels are used
##        - The variable names are only constructed if not given

burst(x, labs = list(group = NULL, group2d = TRUE)) # no group labels
#> $xcols
#> $xcols$V1
#> [1] 1 2 3 4
#> 
#> $xcols$V2
#> [1] 5 6 7 8
#> 
#> $xcols$V3
#> [1]  9 10 11 12
#> 
#> $xcols$V1
#> [1] 1 2 3 4
#> 
#> $xcols$V1
#> [1] 1 2 3 4
#> 
#> $xcols$V2
#> [1] 5 6 7 8
#> 
#> $xcols$V3
#> [1]  9 10 11 12
#> 
#> 
#> $groups
#> [1] 1 1 1 2 3 3 3
#> 
#> $vars
#> [1] 1 2 3 1 1 2 3
#> 
#> $glabs
#> [1] "" "" "" "" "" "" ""
#> 
#> $vlabs
#> [1] "V1" "V2" "V3" "V1" "V1" "V2" "V3"
#> 
burst(x, labs = list(group = NULL)) # no group labels unless groups change
#> $xcols
#> $xcols$V1
#> [1] 1 2 3 4
#> 
#> $xcols$V2
#> [1] 5 6 7 8
#> 
#> $xcols$V3
#> [1]  9 10 11 12
#> 
#> $xcols$V1
#> [1] 1 2 3 4
#> 
#> $xcols$V1
#> [1] 1 2 3 4
#> 
#> $xcols$V2
#> [1] 5 6 7 8
#> 
#> $xcols$V3
#> [1]  9 10 11 12
#> 
#> 
#> $groups
#> [1] 1 1 1 2 3 3 3
#> 
#> $vars
#> [1] 1 2 3 1 1 2 3
#> 
#> $glabs
#> [1] "mat" "mat" "mat" "vec" "df"  "df"  "df" 
#> 
#> $vlabs
#> [1] "V1" "V2" "V3" "V1" "V1" "V2" "V3"
#> 
##  Note: Now the effect of 'group2d' is visible.

##  Partially named list
x <- list(mat = A, vec = 1:4, as.data.frame(A))
burst(x)
#> $xcols
#> $xcols$`mat, V1`
#> [1] 1 2 3 4
#> 
#> $xcols$`mat, V2`
#> [1] 5 6 7 8
#> 
#> $xcols$`mat, V3`
#> [1]  9 10 11 12
#> 
#> $xcols$`vec, V1`
#> [1] 1 2 3 4
#> 
#> $xcols$`, V1`
#> [1] 1 2 3 4
#> 
#> $xcols$`, V2`
#> [1] 5 6 7 8
#> 
#> $xcols$`, V3`
#> [1]  9 10 11 12
#> 
#> 
#> $groups
#> [1] 1 1 1 2 3 3 3
#> 
#> $vars
#> [1] 1 2 3 1 1 2 3
#> 
#> $glabs
#> [1] "mat" "mat" "mat" "vec" ""    ""    ""   
#> 
#> $vlabs
#> [1] "V1" "V2" "V3" "V1" "V1" "V2" "V3"
#> 
burst(x, labs = list(group = NULL, group2d = TRUE)) # no group labels
#> $xcols
#> $xcols$V1
#> [1] 1 2 3 4
#> 
#> $xcols$V2
#> [1] 5 6 7 8
#> 
#> $xcols$V3
#> [1]  9 10 11 12
#> 
#> $xcols$V1
#> [1] 1 2 3 4
#> 
#> $xcols$V1
#> [1] 1 2 3 4
#> 
#> $xcols$V2
#> [1] 5 6 7 8
#> 
#> $xcols$V3
#> [1]  9 10 11 12
#> 
#> 
#> $groups
#> [1] 1 1 1 2 3 3 3
#> 
#> $vars
#> [1] 1 2 3 1 1 2 3
#> 
#> $glabs
#> [1] "" "" "" "" "" "" ""
#> 
#> $vlabs
#> [1] "V1" "V2" "V3" "V1" "V1" "V2" "V3"
#> 
burst(x, labs = list(group = NULL)) # no group labels unless groups change
#> $xcols
#> $xcols$V1
#> [1] 1 2 3 4
#> 
#> $xcols$V2
#> [1] 5 6 7 8
#> 
#> $xcols$V3
#> [1]  9 10 11 12
#> 
#> $xcols$V1
#> [1] 1 2 3 4
#> 
#> $xcols$V1
#> [1] 1 2 3 4
#> 
#> $xcols$V2
#> [1] 5 6 7 8
#> 
#> $xcols$V3
#> [1]  9 10 11 12
#> 
#> 
#> $groups
#> [1] 1 1 1 2 3 3 3
#> 
#> $vars
#> [1] 1 2 3 1 1 2 3
#> 
#> $glabs
#> [1] "mat" "mat" "mat" "vec" ""    ""    ""   
#> 
#> $vlabs
#> [1] "V1" "V2" "V3" "V1" "V1" "V2" "V3"
#> 
burst(x, labs = list(var = NULL)) # no variable labels
#> $xcols
#> $xcols$mat
#> [1] 1 2 3 4
#> 
#> $xcols$mat
#> [1] 5 6 7 8
#> 
#> $xcols$mat
#> [1]  9 10 11 12
#> 
#> $xcols$vec
#> [1] 1 2 3 4
#> 
#> $xcols[[5]]
#> [1] 1 2 3 4
#> 
#> $xcols[[6]]
#> [1] 5 6 7 8
#> 
#> $xcols[[7]]
#> [1]  9 10 11 12
#> 
#> 
#> $groups
#> [1] 1 1 1 2 3 3 3
#> 
#> $vars
#> [1] 1 2 3 1 1 2 3
#> 
#> $glabs
#> [1] "mat" "mat" "mat" "vec" ""    ""    ""   
#> 
#> $vlabs
#> [1] "" "" "" "" "" "" ""
#> 
burst(x, labs = list(group = NULL, var = NULL)) # only group labels and only if groups change
#> $xcols
#> $xcols[[1]]
#> [1] 1 2 3 4
#> 
#> $xcols[[2]]
#> [1] 5 6 7 8
#> 
#> $xcols[[3]]
#> [1]  9 10 11 12
#> 
#> $xcols[[4]]
#> [1] 1 2 3 4
#> 
#> $xcols[[5]]
#> [1] 1 2 3 4
#> 
#> $xcols[[6]]
#> [1] 5 6 7 8
#> 
#> $xcols[[7]]
#> [1]  9 10 11 12
#> 
#> 
#> $groups
#> [1] 1 1 1 2 3 3 3
#> 
#> $vars
#> [1] 1 2 3 1 1 2 3
#> 
#> $glabs
#> [1] "mat" "mat" "mat" "vec" ""    ""    ""   
#> 
#> $vlabs
#> [1] "" "" "" "" "" "" ""
#> 
burst(x, labs = NULL) # neither group nor variable labels
#> $xcols
#> $xcols[[1]]
#> [1] 1 2 3 4
#> 
#> $xcols[[2]]
#> [1] 5 6 7 8
#> 
#> $xcols[[3]]
#> [1]  9 10 11 12
#> 
#> $xcols[[4]]
#> [1] 1 2 3 4
#> 
#> $xcols[[5]]
#> [1] 1 2 3 4
#> 
#> $xcols[[6]]
#> [1] 5 6 7 8
#> 
#> $xcols[[7]]
#> [1]  9 10 11 12
#> 
#> 
#> $groups
#> [1] 1 1 1 2 3 3 3
#> 
#> $vars
#> [1] 1 2 3 1 1 2 3
#> 
#> $glabs
#> NULL
#> 
#> $vlabs
#> NULL
#>