Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. mytable <- function(...) round(x = addmargins(A = cbind(as.matrix(x = ftable(...)),
  2. as.matrix(x = prop.table(x = ftable(...),
  3. margin = 2) * 100)),
  4. margin = 1),
  5. digits = 1)
  6.  
  7. mytable(x = mtcars$gear,
  8. row.vars = 1)
  9.  
  10. [,1] [,2]
  11. 3 15 46.9
  12. 4 12 37.5
  13. 5 5 15.6
  14. Sum 32 100.0
  15.  
  16. mytable(formula = am + vs ~ gear,
  17. data = mtcars)
  18.  
  19. 0_0 0_1 1_0 1_1 0_0 0_1 1_0 1_1
  20. 3 12 3 0 0 100 42.9 0.0 0.0
  21. 4 0 4 2 6 0 57.1 33.3 85.7
  22. 5 0 0 4 1 0 0.0 66.7 14.3
  23. Sum 12 7 6 7 100 100.0 100.0 100.0
  24.  
  25. mytable(formula = am + vs ~ gear,
  26. data = mtcars,
  27. subset = cyl == 6)
  28.  
  29. Error in eval(substitute(subset), data, env) :
  30. ..3 used in an incorrect context, no ... to look in
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement