I have a simple dataframe that contains six samples (nrows=6)
I am trying to make all possible combinations of the data-frame of size 4 samples (nrows=4)
The example data looks like this below
Samples=c("control1","control2","control3","control4","control5","control6")
dosage_mg<-c(0,0,0,0,0,0)
df=data.frame(Samples,dosage_mg)
df
#I want to find all possible combinations of this data frame but in size of 4 samples. I have tried this code below but it just repeats all the values in the sample.
expand.grid(Samples,dosage_mg)
d1 <- expand.grid(Samples = Samples, dosage_mg = dosage_mg)
#I tried the code below and it did not work.
The results should give a list of all possible combinations of dataframes of size(4 rows).
The resulting dataframes may look like the following
Samples=c("control4","control5","control6","control2")
dosage_mg<-c(0,0,0,0)
df_COMBINATION_1=data.frame(Samples,dosage_mg)
Samples=c("control3","control1","control6","control2")
dosage_mg<-c(0,0,0,0)
df_COMBINATION_2=data.frame(Samples,dosage_mg)
Samples=c("control1","control5","control2","control3")
dosage_mg<-c(0,0,0,0)
df_COMBINATION_3=data.frame(Samples,dosage_mg)
head(df_COMBINATION_1)
head(df_COMBINATION_2)
head(df_COMBINATION_3)
and the list goes on until all possible combinations are achieved.
Thank you in advance!