Hi I am looking at when an individual reaches a diagnosis. I have multiple cycles and i am looking to examine when they exit. data frame is smsDatraw smsDatraw$FM_diag_visit <- NA
smsDatraw <-
transform(
smsDatraw,
FM_diag_visit =
# Recode FM_diag_visit by "what_was_done_x" variable
ifelse( what_was_done_1==5 | what_next_1==4 | what_next_1_2==3 | what_next_1_3==2, 1 ,
ifelse( what_was_done_2==5 | what_next_2==3 | what_next_2_2==2 | what_next_2_3==2, 2 ,
ifelse( what_was_done_3==5 | what_next_3==3 | what_next_3_2==2 | what_next_3_3==2, 3 ,
ifelse( what_was_done_4==5 | what_next_4==3 | what_next_4_2==2 | what_next_4_3==2, 4 ,
ifelse( what_was_done_5==5 | what_next_5==3 | what_next_5_2==2 | what_next_5_3==2, 5 ,
ifelse( what_was_done_6==5 | what_next_6==3 | what_next_6_2==2 | what_next_6_3==2, 6 ,
ifelse( what_was_done_7==5 | what_next_7==3 | what_next_7_2==2 | what_next_7_3==2, 7 ,
ifelse( what_was_done_8==5 | what_next_8==3 | what_next_8_2==2 | what_next_8_3==2, 8 ,
ifelse( what_was_done_9==5 | what_next_9==3 | what_next_9_2==2 | what_next_9_3==2, 9 ,
ifelse( what_was_done_10==5 | what_next_10==3 | what_next_10_2==2 | what_next_10_3==2, 10 ,
ifelse( what_was_done_11==5 | what_next_11==3 | what_next_11_2==2 | what_next_11_3==2, 11 ,
ifelse( what_was_done_12==5 | what_next_12==3 | what_next_12_2==2 | what_next_12_3==2, 12 ,
NA ) ) ) ) ) ) ) ) ) ) ) ) )
but when i run the descriptives i get > describe(smsDatraw$FM_diag_visit) smsDatraw$FM_diag_visit n missing distinct Info Mean Gmd 335 1514 3 0.281 1.116 0.2114
Value 1 2 3 Frequency 300 31 4 Proportion 0.896 0.093 0.012
the data in 1 is correct 2 and 3 are not and there should be data for all but 12. is there anything obviously wrong with the code? I am pretty new to this so excuse me if it is a really simple error.
Aucun commentaire:
Enregistrer un commentaire