Mean of one column with respect to another

0 votes
Hi!!

I am new to R and I want to know how to find out the mean of one column with respect to other.

Can someone explain in simple terms?
Jul 25, 2018 in Data Analytics by darklord
• 6,170 points
34 views

1 answer to this question.

0 votes

Consider the inbuilt iris dataset in R.

Use the mean() function from the mosaic package.

mean(iris$Sepal.Length~iris$Species)

This command gives the mean values of Sepal-Length across different species of the iris flower.

And, when you run this command, you will see in the output that “virginica” has the highest sepal length and “setosa” has the lowest sepal length. 

answered Jul 25, 2018 by CodingByHeart77
• 3,690 points

Related Questions In Data Analytics

0 votes
1 answer

How to check row value of one column wrt another column?

Hi ratna, For suppose DF is the DataFrame ...READ MORE

answered Jul 25 in Data Analytics by anonymous
22 views
+1 vote
2 answers

Custom Function to replace missing values in a vector with the mean of values

Try this. lapply(a,function(x){ifelse(is.na(x),mean(a,na.rm = TRUE) ...READ MORE

answered Aug 14 in Data Analytics by anonymous
98 views
0 votes
1 answer

With the help of tidyverse: how to rename a column to a variable name

With the help of Dplyr: rename function ...READ MORE

answered Apr 3, 2018 in Data Analytics by DeepCoder786
• 1,720 points

edited Apr 3, 2018 by DeepCoder786 46 views
0 votes
1 answer

How to calculate group mean and assign it to new data in R

You can use something like this: df$grp.mean.values <- ...READ MORE

answered Jun 27, 2018 in Data Analytics by darklord
• 6,170 points
58 views
0 votes
1 answer

Big Data transformations with R

Dear Koushik, Hope you are doing great. You can ...READ MORE

answered Dec 17, 2017 in Data Analytics by Sudhir
• 1,610 points
54 views
0 votes
2 answers

Transforming a key/value string into distinct rows in R

We would start off by loading the ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,550 points
75 views
0 votes
1 answer

Finding frequency of observations in R

You can use the "dplyr" package to ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,550 points
180 views
0 votes
1 answer

How to write a custom function which will replace all the missing values in a vector with the mean of values in R?

Consider this vector: a<-c(1,2,3,NA,4,5,NA,NA) Write the function to impute ...READ MORE

answered Jul 4, 2018 in Data Analytics by CodingByHeart77
• 3,690 points
187 views
0 votes
1 answer

How to replace NA values in a dataframe with Zero's ?

It is simple and easy: df1<-as.data.frame(matrix(sample(c(NA, 1:10), 100, ...READ MORE

answered Apr 10, 2018 in Data Analytics by CodingByHeart77
• 3,690 points
141 views