Upon executing this code, I get twelve rows of data with a new column A1
. I want a functionality such, that for all "1" appearing in A1
, I should get an average of the corresponding Sepal.Length values,similarly for "2" and "3" and the assign the three average values to a new vector. So in all, a vector with three average values based on the requirement above.
iris1 = iris[1:12,]
a = data.frame(A1=rep(1,4))
b = data.frame(A1=rep(2,4))
c = data.frame(A1 = rep(3,4))
abc = rbind(a,b,c)
abc
iris2 = data.frame(abc,iris1)
View(iris2)