I am trying to create a data frame from my original data frame, where the rows in the new framework will be the average of every 20 rows in the old frame. I found a colMeans function that does the job pretty well, the only problem that still persists is how to change this result vector back to the dataframe, which can be further analyzed.
my code for colMeans: (matrix1 in my original data frame converted to a matrix, that was the only way I managed to get it working)
a<-colMeans(matrix(matrix1, nrow=20));
But here I get a numerical sequence that has all the results concatenated in one column (if I try, for example, as.data.frame (a)). How should I return this result to a dataframe, where each column contains only the results for a specific column name, and not for all average values.
Hope my question is clear, thanks for the help.
source
share