i've 6 dataframes from which i take randomly 3 variables each. I want to store the 18 variables in a dataframe and iterate the operation 1000 times creating 1000 dataframes that i want to store in a single list with a for-loop. I've tried like this:
#create 6 clusters
cluster1 = subset(log_ret_stand,select = which(pam.res$clustering == 1))
cluster2 = subset(log_ret_stand,select = which(pam.res$clustering == 2))
cluster3 = subset(log_ret_stand,select = which(pam.res$clustering == 3))
cluster4 = subset(log_ret_stand,select = which(pam.res$clustering == 4))
cluster5 = subset(log_ret_stand,select = which(pam.res$clustering == 5))
cluster6 = subset(log_ret_stand,select = which(pam.res$clustering == 6))
#Create 1000 ptf from clusters
list_ptf = list ()
for (i in 1:1000) {
list_ptf[[i]] = assign(paste0("ptf", i), data.frame(log_ret_stand[,1], cluster1[, sample(ncol(cluster1), 3)], cluster2[, sample(ncol(cluster2), 3)],cluster3[, sample(ncol(cluster3), 3)], cluster4[, sample(ncol(cluster4), 3)], cluster5[, sample(ncol(cluster5), 3)], cluster6[, sample(ncol(cluster6), 3)]))
}
I'm newbe on R and i know that my codes are very basics. Thank you for your attentions