I am looking to take a data set (df_freeGammas) and summarize certain components of the set. The data set is split into subjects and different test numbers (subject 1, test 1). Some subjects have more than 1 test for them. Each test has a subset of 16 rows of data corresponding to the test and subject. I want to be able to use a loop or nested loop to place the subject number in a results matrix. I have figured out a way to do this, but I keep getting the error: "Error in if (df_freeGammas[n, 2] != df_freeGammas[n + 1, 2]) { : missing value where TRUE/FALSE needed" Please help.
I have tried adding more if loops as well as a while loop.
for (n in 1:nrow(df_freeGammas)){
+ if (df_freeGammas[n,2] != df_freeGammas[n+1,2]){
+ Results[n/16,1] = df_freeGammas[n,1]}
+ else if (df_freeGammas[n,1] != df_freeGammas[n+1,1]){
+ Results[n/16,1] = df_freeGammas[n,1]}
+ else
+ invisible()
I expect the result but without the error message.
Aucun commentaire:
Enregistrer un commentaire