Sorry if this is too simple a question but for the life of me cant sort this out.
I have a data frame with a continuous variable and need to create multiple logical variables based on the value of the continuous variable.
Hopefully the example below illustrates this:
x <- as.integer(rnorm(n=1000, mean=10, sd=5))
y <- 1:1000
df <- data.frame(x,y)
for i in 1:10 {
df$[i] <- ifelse (df$x<[i],1,0)
}
I suspect I am going wrong at the df$[i] expression...any solutions?
Thanks in advance