My data frame is
c1 c2 c3 c100
0.2 0.4 0.9 0
0.2 0.3 0 1
0.1 0.6 1 0.3
I want ot select c1 c2 and c3, the c1 c2 and c4, similarly c1 c2
We can use combn
lst <- combn(df1, 3, FUN = list)
names(lst) <- sapply(lst, function(x) paste(names(x), collapse="_"))
lapply(names(lst), function(x) write.table(lst[[x]], paste0(x, ".csv")))
If it is append 1st and 2nd columns with all the other columns
lst <- lapply(names(df1)[3:100], function(i) df1[c(1:2, i)])
names(lst) <- sapply(lst, function(x) paste(names(x), collapse="_"))
lapply(names(lst), function(x) write.table(lst[[x]], paste0(x, ".csv")))