rdataframetraminer

Mean time spent in each state per cluster - TramineR


I would like to create a table (and not a plot) with the mean time spent in each state per cluster. Is there a way to do this with TramineR?

enter image description here


Solution

  • The mean times for the set of sequences are provided by function seqmeant. Therefore, you could probably simply do

    by(df_new_seq, cl.4fac, seqmeant)
    

    And if you want the result in matrix form

    res <- by(df_new_seq, cl.4fac, seqmeant)
    mres <- matrix(unlist(res), nrow=nrow(res[[1]]), byrow=FALSE)
    rownames(mres) <- rownames(res[[1]])