Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---
- title: "Long table test"
- output: pdf_document
- ---
- Here is a table:
- ```{r setup}
- library (data.table)
- library (pander)
- set.seed(1984)
- longString <- "description string"
- dt <- data.table(id=c(1:3),description=rep(longString,3),value=rnorm(3,mean=10000,sd=1))
- ```
- ```{r pander-table}
- panderOptions('round',2)
- panderOptions('digits',2)
- panderOptions('keep.trailing.zeros',TRUE)
- pander(dt, split.cell = 80, split.table = Inf)
- ```
- -------------------------------
- id description value
- ---- ------------------ -------
- 1 description string 10000
- 2 description string 10000
- 3 description string 10001
- -------------------------------
- ----------------------------------
- id description value
- ---- ------------------ ----------
- 1 description string 10000.41
- 2 description string 9999.68
- 3 description string 10000.64
- ----------------------------------
- > format(c( 10000.41, 9999.68, 10000.64 ), digits=2)
- [1] "10000" "10000" "10001"
- library (data.table)
- library(magrittr)
- library (pander)
- set.seed(1984)
- longString <- "description string"
- dt <- data.table(id = c(1:3),
- description = rep(longString, 3),
- value = rnorm(3, mean = 10000, sd = 1))
- pander(
- x = dt %>%
- mutate(value = value %>% round(2) %>% as.character()),
- split.cell = 80,
- split.table = Inf,
- justify = "ccr"
- )
- ------------------------------------
- id description value
- ---- -------------------- ----------
- 1 description string 10000.41
- 2 description string 9999.68
- 3 description string 10000.64
- ------------------------------------
Add Comment
Please, Sign In to add comment