这似乎是一个相当简单的解决方案,所以提前感谢任何帮助。我有一个表,我试图放在一个R Markdown报告中,我想保留我的值的原始小数位数。我已经制作了一个包含pander和kable的表格,但是由于长的站点名称(在页边距之外,因为某些名称似乎由于某种原因而出现在第二行),因此kable表对于我的页面来说太宽了:
我已经看过用panderOptions改变位数的选项,但是我想保留相应值的小数位数(我没有标准的小数位数作为选项输入,对于纬度/经度来说,2太小了。我也试过了panderOptions("keep.trailing.zeros", TRUE)
,但它似乎只保留了两位小数。有没有办法同时拥有我想要的小数位数和宽度?我愿意接受表格问题(宽度或小数)的解决方案。
我已经通读了:
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
还有其他人,但到目前为止还没有任何工作。
表格的输入:
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")
提前致谢!