Guest User

Untitled

a guest
Feb 19th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. make_stars <- function(pval) {
  2. stars = ""
  3. if(pval <= 0.001)
  4. stars = "***"
  5. if(pval > 0.001 & pval <= 0.01)
  6. stars = "**"
  7. if(pval > 0.01 & pval <= 0.05)
  8. stars = "*"
  9. if(pval > 0.05 & pval <= 0.1)
  10. stars = "."
  11. stars
  12. }
  13.  
  14. library(broom)
  15. library(dplyr)
  16.  
  17. mtcars %>%
  18. lm(mpg ~ wt + qsec, .) %>%
  19. tidy() %>%
  20. mutate(signif = sapply(p.value, function(x) make_stars(x)))
  21.  
  22. term estimate std.error statistic p.value signif
  23. 1 (Intercept) 19.746223 5.2520617 3.759709 7.650466e-04 ***
  24. 2 wt -5.047982 0.4839974 -10.429771 2.518948e-11 ***
  25. 3 qsec 0.929198 0.2650173 3.506179 1.499883e-03 **
Add Comment
Please, Sign In to add comment