samedi 31 janvier 2015

R: Checking dataframe value in "if" statement

I need to fix a mistake in how data was entered in a column, so I wrote a set of "if" statements in a while loop to fix it. But the equal sign in if(df1[n,2] = 1) causes an error. What do I need to change?



while(n<=424){
if(df1[n,2] = 1){
df1[n+1,2] <- df1[1,2]
df1[n+2,2] <- df1[1,2]
n <- n+3

Aucun commentaire:

Enregistrer un commentaire