If I understood correctly, you want to split your data frame into sub data frames where each sub data frame has the same rows
and Col
values. You can do this with split
:
df.split <- with(df, split(df, list(rows, Col)))
head(df.split, 3) # showing 3 of 96 sub data frames
Produces
$A.1
rows Col time activity
1 A 1 5 26
97 A 1 10 91
193 A 1 15 25
289 A 1 20 2
385 A 1 25 95
481 A 1 30 35
$B.1
rows Col time activity
2 B 1 5 64
98 B 1 10 71
194 B 1 15 72
290 B 1 20 45
386 B 1 25 52
482 B 1 30 43
$C.1
rows Col time activity
3 C 1 5 49
99 C 1 10 27
195 C 1 15 35
291 C 1 20 16
387 C 1 25 9
483 C 1 30 94
And here is the toy data I used:
rows <- LETTERS[1:8]
Col <- 1:12
time <- (1:6) * 5
df <- expand.grid(rows=rows, Col=Col, time=time)
df$activity <- sample(1:100, nrow(df), rep=T)