Binomial into binary
Cognitive Semiotics :: Tools :: R
Page 1 of 1
Binomial into binary
As always, this is likely just one possible solution:
"df" is the name of your dataframe
"v" is the name of the variable containing the values you want to turn into binary.
Alternatively, you can use:
Just be aware that it doesn't discriminate correct from incorrect, but assigns the value based on when the value appeared, so if you used a randomized paradigm, you might end up with some vectors having their "correct" listed as 1, but "incorrect" as 1 in others.
If all else fails, you can manually correct your dataframe by doing:
df$v <- as.numeric(as.character(factor(df$v, c("name1", "name2"), labels = c(1, 0))))
"df" is the name of your dataframe
"v" is the name of the variable containing the values you want to turn into binary.
Alternatively, you can use:
df$v <- as.numeric(df$v)-1
Just be aware that it doesn't discriminate correct from incorrect, but assigns the value based on when the value appeared, so if you used a randomized paradigm, you might end up with some vectors having their "correct" listed as 1, but "incorrect" as 1 in others.
If all else fails, you can manually correct your dataframe by doing:
Which will bring up a small window where you can replace the values directly.fix(df)
Santiak- Admin
- Posts : 23
Join date : 2016-02-24
Cognitive Semiotics :: Tools :: R
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|