Description Usage Arguments Value Examples
Many of the specialized functions in numform can change the type of the data from numeric to character causing the table formatting functions in various add-on packages to improperly align the elements. This function passes the columns with a regular expression to detect alignment regardless of column class.
1 2 3 4 5 6 7 8 9 |
x |
A |
left |
A value to print for left aligned columns. |
right |
A value to print for right aligned columns. If |
additional.numeric |
An additional regex to consider as numeric. To turn
off this feature use |
sep |
A string to collapse the vector on. |
... |
ignored. |
Returns a vector of lefts and rights or a string (if sep
is not
NULL
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | 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)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.