As suggested by @Psidom in the comments, a list is better suited for data with such format.
You can try to create a list from your dataframe df1
with split()
:
lst <- split(df1,df1$Group)
> lst
#$L
# Group Value
#1 L 0.04058678
#2 L 0.11657916
#3 L 0.08382576
#4 L 0.17477007
#5 L 0.08214530
#6 L 0.15685707
#7 L 0.08237982
#
#$R
# Group Value
#8 R 0.06680679
#9 R 0.05153584
#10 R 0.08919266
From this list, individual data.frames can be extracted, either by indexing (lst[[1]]
and lst[[2]]
) or by name (lst$L
and lst$R
), which can be saved and treated separately if required.
It has become clear in the comments that a separation into a list of different data.frames is not necessary in this case. If the sole purpose is to perform statistics on the groups, aggregate()
is a simpler option than a preprocessing of the data with split()
.
Here are two examples:
aggregate(Value~Group, df1, mean)
# Group Value
#1 L 0.10530628
#2 R 0.06917843
or
aggregate(Value~Group, df1, sum)
# Group Value
#1 L 0.7371440
#2 R 0.2075353
data:
df1 <- structure(list(Group = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
2L, 2L, 2L), .Label = c("L", "R"), class = "factor"), Value = c(0.04058678,
0.11657916, 0.08382576, 0.17477007, 0.0821453, 0.15685707, 0.08237982,
0.06680679, 0.05153584, 0.08919266)), .Names = c("Group", "Value"
), class = "data.frame", row.names = c("1", "2", "3", "4", "5",
"6", "7", "8", "9", "10"))