I am very new to r an programming and have a basic question (my first one on stackoverflow :) ) I want to delete some rows from a data.frame and use an if-statement on that account. My code is running but it is unfortunately not deleting the correct rows but instead every second row of my dataframe I think.
"myDataVergleich" is the name of my data.frame. "myData$QUESTNNR" is the column by which is decided whether the row is supposed to stay in the dataframe or not.
for(i in 1:nrow(myDataVergleich))
{if(myData$QUESTNNR[i] != "t0_mathe" | myData$QUESTNNR[i] != "t0_bio" | myData$QUESTNNR[i] != "t0_allg2" |
myData$QUESTNNR[i] != "t7_mathe_Version1" | myData$QUESTNNR[i] != "t7_bio_Version1")
{myDataVergleich <- myDataVergleich[-c(i),] }}
What am I doing wrong?
Aucun commentaire:
Enregistrer un commentaire