I have a dataframe that is 28 rows by 64 columns. I would like to generate new dataframes that consist of all possible combinations of 62 columns, named in such a way that I know which columns were dropped. Just to give a sense of scale there should be 2016 different possible combinations, so 2016 new dataframes.
For a dataframe where columns 1 and 2 were dropped I would like to name the new dataframe "df1,2" so I can easily track this.
I have attempted this through a for loop using the following code:
#Generates a matrix of character strings for all different possible combinations (eg. "1,2" "1,3" etc.)
dropped2 = combn(1:64,2)
dropped_codons2 = pasteCols(dropped2,sep=",")
#Attempted for loop to drop all combinations of 2 columns from dataframe and assign to new dataframe (eg. df1,2 = df with first 2 columns dropped)
for (val in dropped_codons2){
assign(paste0(deparse(substitute(df)),val),df[,-c(val)])
}
#Error in -c(val) : invalid argument to unary operator
#The error arises because dropped_codons contains the character string "1,2" as opposed to the comma separated numeric values 1,2. I've tried converting this to numeric using as.numeric but this converts all values to NA through coercion which I believe is due to the comma.
Does anyone have a better solution for this problem? I would ultimately like to be able to expand my analysis to drop all combinations of 3 columns, then 4 columns, etc. but the output for those will be huge so I'm trying to tackle this on a smaller scale first.