Code để tự động liệt kê tài liệu R

Khi các bạn host lên Github thì có thể chèn link để chỉ đến trực tiếp trang sách cần tham khảo. Ví dụ https://tuhocr.netlify.app/r-intro.pdf#page=69

Đặc điểm đồ thị base-R graphics

library(knitr)
library(tidyverse)
library(kableExtra)

ok <- list.files("Folder chứa file pdf và hình trang bìa")
river <- paste0("Link host file pdf", ok)

file_pdf <- grep(pattern = ".pdf", x = river, value = TRUE)
file_image <- grep(pattern = ".jpg|.png", x = river, value = TRUE)

## sắp xếp theo thứ tự thời gian
sub("^.*([0-9]{4}).*", "\\1", file_pdf) -> year_published
names(file_pdf) <- year_published
file_pdf[order(names(file_pdf), decreasing = TRUE)] -> file_pdf

sub("^.*([0-9]{4}).*", "\\1", file_image) -> year_published_img
names(file_image) <- year_published_img
file_image[order(names(file_image), decreasing = TRUE)] -> file_image

## đưa thông tin vào table
gsub(pattern = ".pdf", replacement = "", basename(file_pdf)) -> title_ok

my_bib <- data.frame("Bìa sách" = "", "Tên sách" = seq_along(title_ok),
                     check.names = FALSE)

my_bib$"Title" <- paste0("[", title_ok, "]", "(", ")")

my_bib %>%
  kbl(booktabs = T) %>%
  kable_paper(full_width = F) %>%
  column_spec(1, image = spec_image(
    file_image, 200, 250))  %>%
  kable_styling(font_size = 20)

## trong file ví dụ này thì link các file pdf được ẩn vì copyright.
Bìa sách Tên sách
Jones et al. - 2023 - The R Book
Murrell - 2019 - R Graphics
Teetor - 2019 - R Cookbook
Kassambara - 2017 - R Graphics Essentials for Great Data Visualization
de Vries and Meys - 2015 - R For Dummies
Crawley - 2013 - The R Book
Kassambara - 2013 - Guide to Create Beautiful Graphics in R
Chang - 2012 - R Graphics Cookbook
Murrell - 2012 - R Graphics
Teetor - 2011 - R Cookbook
Wickham - 2009 - ggplot2
Chambers - 2008 - Software for Data Analysis Programming with R
Sarkar - 2008 - Lattice Multivariate Data Visualization with R
Crawley - 2007 - The R Book
Murrell - 2006 - R Graphics
Wilkinson - 2005 - The Grammar of Graphics
Tufte - 2001 - The Visual Display of Quantitative Information
Cleveland - 1993 - Visualizing Data
Cleveland - 1985 - The Elements of Graphing Data
Little and Hills - 1978 - Agricultural experimentation design and analysis

Tham khảo: