0

I am trying to print a table that includes a hyperlink, but when the document renders the hyperlink URL has the prefix "file///" and does not link to the webpage.

Reproducible Example:

---
title: "Untitled"
date: "`r Sys.Date()`"
output: officedown::rdocx_document
---
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
library(flextable)

t1 <- tibble(col1 = c(
  "A"
),
col2 = c(
  "B"
)) %>%
  flextable() %>%
  # Currently using autofit for col widths
  #autofit() #%>%
  flextable::width("col1", 2) %>%
  flextable::width("col2", 5) %>%
  align(align = "left") %>%
  valign(valign = "top") %>% 
  fontsize(size = 11, part = "all") %>%
  # change font
  font(fontname = "Calibri", part = 'all')
  
compose(x = t1, j = 2, i = 1,
        value = as_paragraph("part 1 of text", 
                             hyperlink_text(x = "hyperlink", 
                                            url = "https://www.google.com", props = officer::fp_text(color = "blue", underlined = TRUE)))) 

Session Info: R version 4.1.2 (2021-11-01) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 17763)

Matrix products: default

locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] forcats_0.5.1 stringr_1.4.0 dplyr_1.0.10 purrr_0.3.4 readr_2.1.2 tidyr_1.2.0
[7] tibble_3.1.6 ggplot2_3.3.6 tidyverse_1.3.1 flextable_0.8.2

loaded via a namespace (and not attached): [1] Rcpp_1.0.8.3 lubridate_1.8.0 svglite_2.0.0 here_1.0.1
[5] assertthat_0.2.1 rprojroot_2.0.3 digest_0.6.29 utf8_1.2.2
[9] cellranger_1.1.0 R6_2.5.1 backports_1.4.1 reprex_2.0.1
[13] evaluate_0.15 httr_1.4.2 pillar_1.7.0 gdtools_0.2.3
[17] rlang_1.0.6 readxl_1.3.1 uuid_0.1-4 rstudioapi_0.13
[21] data.table_1.14.0 rmarkdown_2.13 webshot_0.5.2 munsell_0.5.0
[25] broom_1.0.1 modelr_0.1.8 compiler_4.1.2 xfun_0.30
[29] pkgconfig_2.0.3 systemfonts_1.0.4 base64enc_0.1-3 rvg_0.2.5
[33] htmltools_0.5.3 tidyselect_1.2.0 fansi_1.0.3 viridisLite_0.4.0
[37] withr_2.5.0 tzdb_0.3.0 crayon_1.5.1 dbplyr_2.1.1
[41] grid_4.1.2 jsonlite_1.8.0 gtable_0.3.0 lifecycle_1.0.3
[45] DBI_1.1.1 magrittr_2.0.2 officedown_0.2.4 scales_1.2.0
[49] zip_2.2.0 cli_3.4.1 stringi_1.7.6 cachem_1.0.5
[53] fs_1.5.2 broom.helpers_1.9.0 xml2_1.3.3 ellipsis_0.3.2
[57] generics_0.1.2 vctrs_0.4.1 kableExtra_1.3.4 tools_4.1.2
[61] glue_1.6.2 officer_0.4.4 hms_1.1.1 fastmap_1.1.0
[65] yaml_2.3.5 colorspace_2.0-3 gtsummary_1.6.2 gt_0.7.0
[69] rvest_1.0.2 memoise_2.0.0 knitr_1.38 haven_2.5.0

Jessica
  • 75
  • 5

0 Answers0