colsMean: Compute Row-wise Means for Groups of Columns
Description
This function computes the row-wise mean for consecutive groups of columns in a matrix or data frame.
Usage
colsMean(x, ncols)
Value
A numeric matrix with the same number of rows as x and ncol(x) / ncols columns,
where each column is the row-wise mean of a group of ncols columns.
Arguments
x
A numeric matrix or data frame.
ncols
An integer specifying the number of consecutive columns to group together.
Details
The function splits the columns of x into consecutive groups of ncols columns
and calculates the mean of each row for each group. The number of columns in x must
be divisible by ncols.