I want to create several variables, 0/1, that meet a condition with a varying cutoff point. Using an interval of 50 to 100, I'd like to create a 0/1 variable for every point in between those two numbers, where 0 is less than and everything else is 1.
For example:
data1$V1<-ifelse(data1$Value<50, 0, 1)
where data1$Value has the information for the interval and data1$V1 is the first binary vector using 50 as a cutoff, but then data1$V2 would be 51, and so forth.
How can I do this with a loop?
Aucun commentaire:
Enregistrer un commentaire