StateExpand: StateExpand

Description Usage Arguments Details Value References Examples

Description

Transforms dyadic binary data into state-expand-sequences (combines two corresponding sequences into one for every row of a dataframe)

Usage

1
StateExpand(x, pos1, pos2, replace.na = FALSE)

Arguments

x

Dataframe or matix containing the sequences that should be combined

pos1

a vector that indicates all columns of the first sequence

pos2

a vector that indicates all columns of the second sequence

replace.na

a numeric that is used for replacement. If FALSE: no replacement will take place! 0 is handled as zero in this case not als FALSE!

Details

Takes a dataframe or matrix with dyadic binary data in wide data format, that is:

and transforms it into state-expand-sequences:

why/how to use:

Value

returns a matrix with the combined sequences.

References

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
38
39
40
41
42
43
44
45
46
 # Example 1
 data(CouplesCope) # Load sample data
 CouplesCope[1:5,] # inspect first five cases

 my.expand<-StateExpand(CouplesCope, 2:49, 50:97)
 my.expand[1:5,] # inspect first five cases of the combined sequences



 # Example 2: with NA replacement
 data(CouplesCope)
 
 # copy part of the example data
 # excluding code and EDCm for simplification
 na.CouplesCope<-CouplesCope[,2:97] 
 
   
 # fill it with 10% NA's as an example:
 na.CouplesCope[matrix(sample(c(TRUE, rep(FALSE,9)),64*96, TRUE), 64, 96)]<-NA 
 na.CouplesCope[1:5,] # inspect the first 5 cases
 
 # demonstrate na.replace: combine states and fill NA's with zeros!
 my.expand<-StateExpand(na.CouplesCope, 1:48, 49:96, replace.na=0) 
 my.expand[1:5,] # inspect the first 5 cases



## Not run: 
 # Example 3: Use StateExpand for further analyis 
 #            or plotting using the Package TraMineR
              
 # install.packages("TraMineR") # install "TraMineR" for graphical analysis
 library(TraMineR) #load TraMineR

 my.expand<-StateExpand(CouplesCope, 2:49, 50:97) # create combined sequences

 # create labels for plot
 couple.labels <-c("no reaction", "stress only", "coping only", "both reactions")  
 
 # create a sequence object (the way TraMineR represents sequences)
 couple.seq <- seqdef(my.expand, labels = couple.labels) 
 seqdplot(couple.seq)

 detach(TraMineR) # unloading TraMineR

## End(Not run)

PeFox/DySeq documentation built on May 8, 2019, 1:28 a.m.