# 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)
Run the code above in your browser using DataLab