How do you calculate the mean of a column in R language?
In the R language, the mean() function can be used to calculate the average of a column of data. Assuming the data is stored in a vector x, the following code can be used to calculate its average:
mean(x)
If the data is stored in a dataframe with the name “df” and column named “column_name”, you can use the following code to calculate the average of that column:
mean(df$column_name)