Guest User

Untitled

a guest
Jan 16th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. library(dplyr)
  2. library(ggplot2)
  3. data(iris)
  4.  
  5. setosa <- filter(iris, Species == "setosa")
  6. versicolor <- filter(iris, Species == "versicolor")
  7. virginica <- filter(iris, Species == "virginica")
  8. median1 <- round(median(setosa$Sepal.Length), 1)
  9. mean1 <- round(mean(setosa$Sepal.Length), 1)
  10. median2 <- round(median(versicolor$Sepal.Length), 1)
  11. mean2 <- round(mean(versicolor$Sepal.Length), 1)
  12. median3 <- round(median(virginica$Sepal.Length), 1)
  13. mean3 <- round(mean(virginica$Sepal.Length), 1)
  14.  
  15. print(ggplot(data = iris) +
  16. geom_histogram(aes(x = Sepal.Length, y = ..density..)) +
  17. facet_wrap(~ Species) +
  18. geom_text(aes(x = 6.7, y = 1.3),
  19. label = noquote("median = nmean = "),
  20. hjust = 0))
Add Comment
Please, Sign In to add comment