library(psych) stats=read.delim('Clust_task_extract.txt') dataTable=read.table('dataTable_CSPvCSM_AcqvRet',header=T) dataStats=cbind(dataTable,stats) tableFill=read.delim('Clust_task_tableFILL.txt',header=T) statName=stats names(statName)[grep('Mean',names(statName))]=trimws(tableFill$within) dataStatsName=cbind(dataTable,statName) describeBy(statName[,-c(1:2)],list(dataTable$Task),mat=T,fast=T)