msboxes_R | R Documentation |
msboxes_R will create a json file containing parameters that will help MSMplus to automatically create the multi-state graph of each specific setting. However, the user has the option to design and create the multistate graph within the app as well.
msboxes_R(
data,
id,
yb,
xb,
boxwidth = 0.1,
boxheight = 0.1,
tstop,
vartime = 1,
tmatrix,
scale = 1,
msm = FALSE,
jsonpath = NULL,
name = "msboxes_R.json"
)
data |
Provide a dataset that is properly formatted for a multi-state analysis (eg. after msprep()) |
id |
Provide an indentity variable |
yb |
Provide a vector of values for the y coordinates of the state boxes of the multi-state graph you want to create |
xb |
Provide a vector of values for the x coordinates of the state boxes of the multi-state graph you want to create |
boxwidth |
Provide the width of the state boxes of the multi-state graph you want to create (default 0.1) |
boxheight |
Provide the height of the state boxes of the multi-state graph you want to create (default 0.1) |
tstop |
Provide the Tstop variable of your dataset |
vartime |
A vector of time points at which the user wants to count the number of people in each state and the number of people that have made each transition |
tmatrix |
The transition matrix (e.g transMat(x = list(c(2, 3),c(3), c() )) ). |
scale |
rescale time value |
msm |
In case the msm package is used, the function uses statetable.msm to calculate the frequencies.Default: FALSE |
jsonpath |
specify the path of the folder that the json file should be saved, Default: "" saves the json file to the current working directory |
name |
Specify the name of the output json file, Default: 'msboxes_R.json' |
DETAILS
Nstates, Ntransitions, xvalues, yvalues,boxwidth, boxheight, statenames, transnames, the start and end coordinates of the arrows that connect the state boxes, tmat, number of people in each state and the number of people that have made each transition
## Not run:
#EXAMPLE
library("mstate")
library("dplyr")
library("RJSONIO")
head(ebmt)
tmat <- transMat(x = list(c(2, 3),c(3), c() ), names = c("Transplant", "Platelet Recovery", "Relapse/Death" ) )
ebmt$age2= recode(ebmt$age, ">40" =0, "20-40"=1,"<=20" =0 )
ebmt$age3= recode(ebmt$age, ">40" =1, "20-40"=0,"<=20" =0 )
msebmt <- msprep(data = ebmt, trans = tmat, time = c(NA, "prtime", "rfstime"), status = c(NA, "prstat", "rfsstat"), keep=c("age2","age3"))
results=MSMplus::msboxes_R(data=msebmt,id= msebmt$id, yb=c(0.3,0.5,0.75),
xb=c(0.5,0.2,0.7),boxwidth=0.1,boxheight=0.1,
tmatrix= tmat, tstop=msebmt$Tstop,vartime=c(seq(0,10,by=1)),scale=365.25,
jsonpath="", name="msboxes_EBMT_R.json" )
results
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.