I would like to create a data frame with several different columns containing means, after which the sd is shown in brackets. To give an example:
df <- iris
mean <- aggregate(df[,1:4], list(iris$Species), mean)
sd <- aggregate(df[,1:4], list(iris$Species), sd)
view(mean)
Group.1 Sepal.Length Sepal.Width Petal.Length Petal.Width
1 setosa 5.006 3.428 1.462 0.246
2 versicolor 5.936 2.770 4.260 1.326
3 virginica 6.588 2.974 5.552 2.026
view(sd)
Group.1 Sepal.Length Sepal.Width Petal.Length Petal.Width
1 setosa 0.3524897 0.3790644 0.1736640 0.1053856
2 versicolor 0.5161711 0.3137983 0.4699110 0.1977527
3 virginica 0.6358796 0.3224966 0.5518947 0.2746501
Now I would like to have something like this:
Group.1 Sepal.Length Sepal.Width Petal.Length Petal.Width
1 setosa 5.0 (0.35) 3.4 (0.38) 1.5 (0.17) 0.2 (0.11)
2 versicolor 5.9 (0.52) 2.8 (0.31) 4.3 (0.47) 1.3 (0.20)
3 virginica 6.6 (0.64) 3.0 (0.32) 5.6 (0.55) 2.0 (0.27)
I reckon there should be a way using the paste
function, but I can't figure out how.