Imagine you need to calculate the mean of each column in a data frame in R. How would you do this?

  • Use the colMeans() function with the data frame as an argument
  • Use the mean() function with the data frame as an argument
  • Use the apply() function with the appropriate margin argument and the mean() function
  • Use the rowMeans() function with the data frame as an argument
To calculate the mean of each column in a data frame in R, you would use the colMeans() function with the data frame as an argument. The colMeans() function computes the mean values across each column of the data frame.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *