I want to create a new column that will label a certain amount of columns 1 and the remaining number of columns 0. If I want 20% of my columns to have this option I can get close by taking:
test$Rand_Num <- sample(1:5, nrow(test), replace=TRUE) test$Output <- ifelse(test$Rand_Num==1,1,0)
However I would like to be able to say if I had 1000 columns then 200 are randomly 1 and the rest are labeled as 0 that I can quickly change to 30%, etc.. for different scenarios.
Thanks!