2

I have a table that I am trying to place in an rmarkdown pdf document. I am also trying to format the table so that the station numbers are clickable links for associated webpages. I have created a function to transform the original table into a table with links in rmarkdown format. All works well except that the column that the links are in is so large that none of the other columns appear on the page. I have tried changing the width of the figure in the chunk details line, and changing the width of the table in the kable line with format.args= (width = 15). Neither of these options change the formatting, and I have not found any similar questions/answers online. This question: Including links within Rmarkdown tables (pdf) appears to be similar but as my table will produce a table hundreds of pages long, I am hoping to stick to a way of using the links table I have created.

The kable function: kable(local.select, format = "markdown", row.names= FALSE, format.args= (width = 15))

The issue (very wide column width when links are added to station numbers, and all other columns are pushed off the page): enter image description here

The original table:

structure(list(Station = structure(1:3, .Label = c("01AF002", 
"01AP002", "01AP004"), class = "factor"), FLOW_TYPE = structure(c(1L, 
1L, 1L), .Label = "Normal", class = "factor"), Reg. = structure(c(2L, 
1L, 1L), .Label = c(" False", " True"), class = "factor"), OperSched = structure(c(1L, 
1L, 1L), .Label = " Continuous", class = "factor"), DrainageArea = c(21900L, 
668L, 1100L), PEARSEDA = structure(c(1L, 1L, 1L), .Label = "Saint John - St. Croix", class = "factor")), class = "data.frame", row.names = c(NA, 
-3L), .Names = c("Station", "FLOW_TYPE", "Reg.", "OperSched", 
"DrainageArea", "PEARSEDA"))

The link-converted table:

structure(list(`Station Number` = structure(1:3, .Label = c("[01AF002](http://wateroffice.ec.gc.ca/report/report_e.html?mode=Graph&type=h2oArc&stn=01AF002&dataType=Daily&parameterType=Flow&year=2013&scale=normal)", 
"[01AP002](http://wateroffice.ec.gc.ca/report/report_e.html?mode=Graph&type=h2oArc&stn=01AP002&dataType=Daily&parameterType=Flow&year=2013&scale=normal)", 
"[01AP004](http://wateroffice.ec.gc.ca/report/report_e.html?mode=Graph&type=h2oArc&stn=01AP004&dataType=Daily&parameterType=Flow&year=2013&scale=normal)"
), class = "factor"), `Water Quantity` = structure(c(1L, 1L, 
1L), .Label = "Normal", class = "factor"), `Water Flow` = structure(c(2L, 
1L, 1L), .Label = c(" False", " True"), class = "factor"), `Sampling Frequency` = structure(c(1L, 
1L, 1L), .Label = " Continuous", class = "factor"), `Drainage Area` = c(21900L, 
668L, 1100L), PEARSEDA = structure(c(1L, 1L, 1L), .Label = "Saint John - St. Croix", class = "factor")), .Names = c("Station Number", 
"Water Quantity", "Water Flow", "Sampling Frequency", "Drainage Area", 
"PEARSEDA"), class = "data.frame", row.names = c(NA, -3L))

The original table in the rmarkdown document (as I would like it to appear when there are links associated with the station names):

enter image description here

Is there a way to put links in a table without the extra spacing it seems to create in the links column? Thanks for any suggestions.

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

0 Answers0