Graph flow chart of transition from states

后端 未结 4 694
忘掉有多难
忘掉有多难 2020-12-07 12:00

I\'m trying to find a way to graph something like this in R:

\"Image

It is a tr

4条回答
  •  被撕碎了的回忆
    2020-12-07 12:23

    This is just to show that plotmat can be used for this:

    library(diagram)
    
    M  <- matrix(nrow = 4, ncol = 4, byrow = TRUE, data = 0)
    C <- M
    A <- M
    M[2, 1] <- "f11" 
    M[4, 1] <- "f12" 
    M[2, 3] <- "f21" 
    M[4, 3] <- "f22"
    C[4, 1] <- -0.1
    C[2, 3] <- 0.1
    A[2, 1] <- A[2, 3] <- A[4, 3] <-4
    A[4, 1] <-  8
    
    col   <- M
    col[] <- "red"
    col[2, 1] <- col[4, 1] <- "blue"
    plotmat(M, pos = c(2, 2), curve = C, name = c(1,1,2,2),
            box.size=c(0.05,0.03,0.03,0.05), box.prop = 2,
            arr.lwd=A,
            lwd = 1, box.lwd = 2, box.cex = 1, cex.txt = 0.8, 
            arr.lcol = col, arr.col = col, box.type = "rect",
            lend=3)
    

    enter image description here

    Some fine-tuning and possibly modifying the function should give you the graph you want.

提交回复
热议问题