Here is a bit of data:
'CFB'=change from baseline.
I want to obtain the weighted mean and SD for each time point, then calculate the weighted mean change and SE from baseline at each time point. When I run the code now, if any subject has an NA at a time point an NA is returned instead of the mean/SE. I'd like to either find a way to remove the NA from the correct position in the vector of weights corresponding to the position of the NAs or make the functions ignore the NA. or if someone has an entirely different way of approaching this problem I would love to hear it!
tribble(
~id, ~BASELINE, ~DAY_1_CFB, ~WEEK_2_CFB, ~WEEK_4_CFB, ~WEEK_8_CFB, ~WEEK_12_CFB,
2 , 3 , 5 , 7 , 12 , NA, NA,
44 , 5 , -1 , 4 , 0 , 1 , 0 ,
429 , 3 , 4 , NA, 5 , 4 , NA)
weights=as.vector(c(0.7736762, 0.6889595, 0.8251115, 0.7411247, 0.8452947, 0.8750179, 1.1460260,
1.0778067, 0.8804010, 0.8923645, 0.9545200, 0.7158591, 0.8908700, 0.8867936,
0.9149441, 1.7827734, 0.9617388, 0.9031469, 0.9069772, 0.9239883, 0.9024339))
Does this help?