library(dplyr); library(knitr); library(kableExtra);
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
##
## Attaching package: 'kableExtra'
## The following object is masked from 'package:dplyr':
##
## group_rows
library(tidyr); library(stringr)
options(knitr.kable.NA = '')
Simple table manually generated
df <- data.frame(a = c(1, 2),
b = c("[CRAN](https://cran.r-project.org)", "https://github.com"))
knitr::kable(df)
a | b |
---|---|
1 | CRAN |
2 | https://github.com |
My example of an auto generated name
hw <- data.frame(filenames = paste0('hw/', list.files("hw", pattern='template|*.pdf|*.html|*.docx')))
out.hw <- hw %>% mutate(name = gsub("hw/|_template", "", filenames),
type = str_extract(hw$filenames,".{3}$"),
type = ifelse(type=="tml", "html", type),
type = ifelse(type=="ocx", "docx", type),
nam = gsub(".html|.pdf|.Rmd|.docx", "", name),
link = sprintf("[%s](%s)",type, filenames))
x = out.hw %>% select(link, type, nam) %>%
reshape2::dcast(nam~type, value.var="link") %>%
kable(format="html") %>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive" ,"bordered"),
full_width=FALSE, position = "left")
gsub("<thead>.*</thead>", "", x)
hw00_setup | html | ||
hw01_data_entry | docx | html |
sessionInfo()
## R version 4.2.1 (2022-06-23 ucrt)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 10 x64 (build 19043)
##
## Matrix products: default
##
## locale:
## [1] LC_COLLATE=English_United States.utf8
## [2] LC_CTYPE=English_United States.utf8
## [3] LC_MONETARY=English_United States.utf8
## [4] LC_NUMERIC=C
## [5] LC_TIME=English_United States.utf8
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] stringr_1.4.0 tidyr_1.2.0 kableExtra_1.3.4 knitr_1.39
## [5] dplyr_1.0.9
##
## loaded via a namespace (and not attached):
## [1] Rcpp_1.0.9 plyr_1.8.7 highr_0.9 pillar_1.8.0
## [5] bslib_0.4.0 compiler_4.2.1 jquerylib_0.1.4 tools_4.2.1
## [9] digest_0.6.29 viridisLite_0.4.0 jsonlite_1.8.0 evaluate_0.15
## [13] lifecycle_1.0.1 tibble_3.1.8 pkgconfig_2.0.3 rlang_1.0.4
## [17] cli_3.3.0 DBI_1.1.3 rstudioapi_0.13 yaml_2.3.5
## [21] xfun_0.31 fastmap_1.1.0 httr_1.4.3 xml2_1.3.3
## [25] systemfonts_1.0.4 generics_0.1.3 vctrs_0.4.1 sass_0.4.2
## [29] webshot_0.5.3 tidyselect_1.1.2 svglite_2.1.0 glue_1.6.2
## [33] R6_2.5.1 fansi_1.0.3 rmarkdown_2.14 reshape2_1.4.4
## [37] purrr_0.3.4 magrittr_2.0.3 ellipsis_0.3.2 scales_1.2.0
## [41] htmltools_0.5.3 assertthat_0.2.1 rvest_1.0.2 colorspace_2.0-3
## [45] utf8_1.2.2 stringi_1.7.8 munsell_0.5.0 cachem_1.0.6