问题
In R, the default method when using a factor variable in regression is to use contrasts. I.E we set a reference class, and then the results are reported as (factor) vs. reference.
For example, if we had 3 groups, and set 1 to be the reference group, then the results will be (2 vs 1) and (3 vs 1). But we don't get to see 3 vs 2. I know that you can get this by rerunning the regression and re-leveling with 2 as the reference class. But is there any way to get all comparisons in one line of code, instead of running two regression calls?
来源:https://stackoverflow.com/questions/33698979/display-all-comparisons-for-factor-variables-in-r-for-lm-or-coxph