merges the most recent wealth module onto the corresponding core data. i.e. if breaks=c(3,6,9), the TM was asked in waves 3,6 and 9. therefore merge TM_3 onto cores 1-3, merge TM_6 onto 4-6, etc

# S3 method for idx
merge(core, topic, breaks = c(3, 6, 9, 12),
  topic.names = NULL)

Arguments

core

list of core datasets

topic

list of topical datasets

breaks

numeric vector of waves where a TM was asked.

topic.names

NULL by default assumes names of topic are like "TM_2". if not, supply names here.

Examples

co <- lapply(1:12, function(x) data.table(ssuid=1:4,covar=rnorm(4),key="ssuid"))
#> Error in data.table(ssuid = 1:4, covar = rnorm(4), key = "ssuid"): could not find function "data.table"
br <- c(2,5,9,12) tm <- lapply(1:5, function(x) data.table(ssuid=1:4,tmvar=10*c(1,br)[x] + sample(1:4,size=4),key="ssuid"))
#> Error in data.table(ssuid = 1:4, tmvar = 10 * c(1, br)[x] + sample(1:4, size = 4), key = "ssuid"): could not find function "data.table"
names(tm) <- paste0("TM_",c(1,br)) # don't merge first TM
#> Error in names(tm) <- paste0("TM_", c(1, br)): object 'tm' not found
merge.idx(core=co,topic=tm,breaks=br)
#> Error in merge.idx(core = co, topic = tm, breaks = br): could not find function "merge.idx"