unfold.folded: Unfold a Folded Data.frame

Description Usage Arguments Details Value See Also Examples

Description

Unfolds a folded data.frame, or part thereof.

Usage

1
2
## S3 method for class 'folded'
unfold(x, ..., sort = TRUE)

Arguments

x

folded data.frame

...

variables to unfold, given as unquoted anonymous names

sort

whether to sort the result by groups values

Details

By default, the entire data.frame is unfolded, possibly giving back something originally passed to fold(). If ... is specified, only selected items (given as anonymous unquoted arguments) are unfolded. Values stored as encodings are converted to factor. The result has a groups attribute: a character vector of column names in the result whose interaction makes rows unique.

Value

class 'unfolded': data.frame with a groups attribute (character)

See Also

unfold

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
library(magrittr)
library(dplyr)
data(eventsf)
eventsf %>% unfold
eventsf %>% unfold(DV,PRED)
x <- events %>% 
  filter(CMT == 2) %>% 
  select(ID, TIME, TAD, DV, BLQ, LLOQ, SEX) 
x
attr(x,'groups') <- c('ID','TIME')

# less than 10 values of DV, so BLQ looks like an encoding
y <- x  %>% fold(meta=list(DV~BLQ,BLQ~LLOQ))
y %>% data.frame

# reducing the tolerance forces BLQ to match by groups (ID, TIME) instead of DV value
z <- x  %>% fold(meta=list(DV~BLQ,BLQ~LLOQ),tol=3)
z

# recursive unfold, since LLOQ is an attribute of BLQ, which is an attribute of DV
unfold(y)
unfold(z)
y %>% unfold(DV)
y %>% unfold(BLQ)
y %>% unfold(LLOQ)
y %>% unfold(SEX)
y %>% unfold(TAD)
y %>% unfold(DV,SEX)
y %>% unfold(TAD,SEX)

bergsmat/origami documentation built on May 12, 2019, 3:08 p.m.