I just started to work with R, because I need to do a Lasso regression. To get familiar with the system, I created a very plain matrix with 10 variables and 80 observations each using:
testmatrix<-matrix(rnorm(800),80,10)
I want the 10th variable to be the binary response variable. I already named the 10th variable "responsible_var", and now I would like to transform it into values either 1 (for >1) or 0 (for <1). I used the ifelse function:
testmatrix$responsible_var <- ifelse(testmatrix$responsible_var>0, 1, 0)
But it keeps telling me:
Error in testmatrix$response_var : $ operator is invalid for atomic vectors
What is the problem?