How to split data frame into groups, combine rows
If I understood you correctly, you want to vertically split your data frame and horizontally union the resulting data frames. Here is an example for what I would do in this case:

#assuming exemplary dataset
dataset &lt;- data.frame(matrix(rnorm(n = 27 * 15 * 10), nrow = 10));
colnames(dataset) &lt;- paste(
  as.character(sites18)
  ,rep(1:27, length.out = 27 * 15)
  ,sep = "_");
str(dataset);

#create list of data frames using a vertical split
(list_df_by_group &lt;- lapply(
  names
  ,function(name) dataset[, paste(rep(name, 27), 1:27, sep = "_")]));
names(list_df_by_group) &lt;- names;
str(list_df_by_group);

#horizontally union data frames
final_dataset &lt;- data.frame(matrix(ncol = 28, nrow = 0));
colnames(final_dataset) &lt;- c("group", as.character(1:27));
for(name in names){
  colnames(list_df_by_group[[name]]) &lt;- as.character(1:27);
  final_dataset &lt;- rbind(
    final_dataset,
    cbind(
      data.frame(group = rep(name, nrow(list_df_by_group[[name]])))
      ,list_df_by_group[[name]]));
}
str(final_dataset);