1

This seems like a fairly straightforward fix, so thanks in advance for any help. I have a table that I am trying to place in an R Markdown report, and I would like to keep the original number of decimal places for my values. I have made a table with both pander and kable, but the kable table is too wide for my page due to long station names (outside the margins, although some names seem to go to a second line for some reason):

enter image description here

And the pander table rounds the values (but is the width that I would like): enter image description here

I have seen options for changing the number of digits with panderOptions, but I want to keep the number of decimal places as they are for the respective values (I don’t have a standard number of decimal places to input as an option, as 2 would be too little for Latitude/Longitude). I have also tried panderOptions("keep.trailing.zeros", TRUE) but it still seems to only retain two decimal places. Is there any way to have both the decimal places and width I am looking for? I’d be open to a solution to either table issue (width or decimals). I have read through:

Control number of decimal places on xtable output in R

How to set the number of decimals in report produced with knitr/pander?

pander number of digits after decimal point

And others, but nothing has worked as of yet.

Dput for the table:

structure(list(REGIONAL_OFFICE_ID = c("2", "2", "2", "2", "5", 
"5", "5", "5"), STATION_NUMBER = c("08GD004", "08GD004", "08NL039", 
"08NL039", "02ED017", "02ED017", "02GA005", "02GA005"), STATION_NAME = c("HOMATHKO RIVER AT THE MOUTH", 
"HOMATHKO RIVER AT THE MOUTH", "SIWASH CREEK NEAR PRINCETON", 
"SIWASH CREEK NEAR PRINCETON", "HOG CREEK NEAR VICTORIA HARBOUR", 
"HOGG CREEK NEAR VICTORIA HARBOUR", "IRVINE RIVER NEAR SALEM", 
"IRVINE RIVER NEAR SALEM"), LATITUDE = c(50.9895286560059, 50.9863586425781, 
49.662971496582, 49.6628112792969, 44.7260589599609, 44.7260589599609, 
43.6967315673828, 43.6935997009277), LONGITUDE = c(-124.918113708496, 
-124.918640136719, -120.335357666016, -120.33553314209, -79.7789688110352, 
-79.7789688110352, -80.4453811645508, -80.4453125), DRAINAGE_AREA_GROSS = c(5680, 
5680, 263, 263, 65.1999969482422, 65.1999969482422, 168.330001831055, 
168.330001831055)), .Names = c("REGIONAL_OFFICE_ID", "STATION_NUMBER", 
"STATION_NAME", "LATITUDE", "LONGITUDE", "DRAINAGE_AREA_GROSS"
), row.names = c(3L, 7L, 4L, 8L, 1L, 5L, 2L, 6L), class = "data.frame")

Thanks in advance!

Community
  • 1
  • 1
acersaccharum
  • 665
  • 1
  • 5
  • 6

0 Answers0