Browsed by
Tag: colMeans()

In R, how to add extra column and row to calculate mean respectively?

In R, how to add extra column and row to calculate mean respectively?

Let’s generate one data table. Now, I’d like to calculate mean of each column and row. For example, I want to calculate mean of ENV1 to ENV5, and also CV1 to CV5. First, I’ll calculate mean of each row (ENV1 to ENV 5). I discarded Environment row (dataA %>% select(-Environment)) because it’s not a numeric. Now, I’ll calculate mean of each column (CV1 to CV5). Now, mean of each column and row was calculated.