I tried to multiply it by the vector of cost vectorMedExp, where each cost corresponds to the disease state. I have tried the following methods:
< /p>
commercialMedExp * states0CommercialA
But it seems that the multiplication occurs in columns instead of across rows. Can someone help me with the correct syntax?
commercialMedExp0A <- t(apply(states0CommercialA, 1, function(x){ x * commercialMedExp}))
As long as the number of columns in states0CommericialA is the same as the length of commercialMedExp, it should work. If not, you must Subset the data. For example, if the disease state is in columns 13 to 18
commercialMedExp0A <- t(apply(states0CommercialA[,c(13:18 )], 1, function(x){ x * commercialMedExp}))
I have a disease matrix with the state state0CommercialA, where the column is the state (ie "no disease", "Illness", "Death"), the line is the model period (ie, 1, 2, 3, 4, etc.).
I tried to multiply it by the vector of cost vectorMedExp, each of which The cost corresponds to the disease state. I have tried the following methods:
commercialMedExp * states0CommercialA
But it seems that the multiplication occurs in columns instead of interrows. Can someone use it correctly Does the grammar help me?
It’s like
commercialMedExp0A <- t(apply(states0CommercialA, 1, function (x){ x * commercialMedExp}))
As long as the number of columns in states0CommericialA is the same as the length of commercialMedExp, it should work. If not, the data must be subsetted. For example, if the disease states In columns 13 to 18
commercialMedExp0A <- t(apply(states0CommercialA[,c(13:18)], 1, function(x){ x * commercialMedExp}))