I'm trying to compare different values in rows. I need to check if there's a 1, or 0, in a row, and then calculate values for a new column "error_A" according to that row. I used an ifelse() function before, like so:
df2$error_A = ifelse(df2$ns0_nns1 == 1, 1-df$A_pred, df$A_pred)
Here's a few lines of my data so it makes more sense what I'm trying to do:
essay ns0_nns1 A_pred B_pred
1 1 0.558 0.37
2 0 0.293 0.654
3 0 0.545 0.849
4 0 0.432 0.698
5 1 0.651 0.404
When I do this I get the error "replacement has length zero".
Aucun commentaire:
Enregistrer un commentaire