# NOT RUN {
CO <- CO2
CO[] <- lapply(CO, as.character)
alignment(CO)
head(CO2)
# }
# NOT RUN {
library(dplyr)
library(pander)
library(xtable)
set.seed(10)
dat <- data_frame(
Team = rep(c("West Coast", "East Coast"), each = 4),
Year = rep(2012:2015, 2),
YearStart = round(rnorm(8, 2e6, 1e6) + sample(1:10/100, 8, TRUE), 2),
Won = round(rnorm(8, 4e5, 2e5) + sample(1:10/100, 8, TRUE), 2),
Lost = round(rnorm(8, 4.4e5, 2e5) + sample(1:10/100, 8, TRUE), 2),
WinLossRate = Won/Lost,
PropWon = Won/YearStart,
PropLost = Lost/YearStart
)
dat %>%
group_by(Team) %>%
mutate(
`%ΔWinLoss` = fv_percent_diff(WinLossRate, 0),
`ΔWinLoss` = f_sign(Won - Lost, '<b>+</b>', '<b>–</b>')
) %>%
ungroup() %>%
mutate_at(vars(Won:Lost), .funs = ff_denom(relative = -1, prefix = '$')) %>%
mutate_at(vars(PropWon, PropLost), .funs = ff_prop2percent(digits = 0)) %>%
mutate(
YearStart = f_denom(YearStart, 1, prefix = '$'),
Team = fv_runs(Team),
WinLossRate = f_num(WinLossRate, 1)
) %>%
as.data.frame() %>%
pander::pander(split.tables = Inf, justify = alignment(.))
alignment(CO, 'l', 'r')
CO %>%
xtable(align = c('', alignment(CO, 'l', 'r'))) %>%
print(include.rownames = FALSE)
CO %>%
xtable(align = c('', alignment(CO, 'l|', 'r|'))) %>%
print(include.rownames = FALSE)
# }
Run the code above in your browser using DataLab