nutterb / pixiedust

Tables So Beautifully Fine-Tuned You Will Believe It's Magic.
180 stars 18 forks source link

Feature request: Substitute SEs, t-values, p-values #12

Closed ghost closed 9 years ago

ghost commented 9 years ago

Have not found that feature but would find it very useful: exchanging the standard SEs, t- and p-values e. g. from regression modells by user specified values (derived by e. g. robust methods (e. g. package sandwich)). Formatting packages like stargazer support such substitutions.

nutterb commented 9 years ago

This is on my to do list. I had planned to write a function to allow the user to change out a column. I had in mind the term column so that I could put in variable labels, or something more readable than factor(am), but I can make generic enough that it works for any column in the table.

nutterb commented 9 years ago

And done.

dust(fit) %>%
  sprinkle(cols = 1, 
           replace = c("Intercept", "Quarter Mile", "Transmission", 
                       "Weight", "Four Gear", "Five Gear")) %>%
  sprinkle(cols = 2:5, round = 3)

          term estimate std.error statistic p.value
1    Intercept    9.365     8.373     1.118   0.274
2 Quarter Mile    1.245     0.383     3.252   0.003
3 Transmission    3.151     1.941     1.624   0.117
4       Weight   -3.926     0.743    -5.286       0
5    Four Gear   -0.268     1.655    -0.162   0.873
6    Five Gear    -0.27     2.063    -0.131   0.897
ghost commented 9 years ago

Great! So for substituting std.errors I would do sprinkle(cols = 2, replace = c(1, 2, 3, 4, 5, 6))? Sure, one would substitute t statistic and p.value as well, as all of them are related.

nutterb commented 9 years ago

I think you would want sprnkles( cols = 3, replace = c(1, 2, 3, 4, 5, 6)). (the SE's are in the third column), and for all three columns sprinkle(cols = 3:5, replace=c(se1:se6, t1:t6, p1:p6)) (excuse my psuedocode)