Google News
logo
R - Interview Questions
How can we find the mean of one column with respect to another?
In iris dataset, there are five columns, i.e., Sepal.Length, Sepal.Width, Petal.Length, Petal.Width and Species. We will calculate the mean of Sepal-Length across different species of iris flower using the mean() function from the mosaic package.
 
mean(iris$Sepal.Length~iris$Species)
Advertisement