R Cheatsheets Search Table

Photo by Michael Dziedzic on Unsplash

Interactive Table

Source Code

DT::datatable({
# https://stackoverflow.com/questions/25485216/how-to-get-list-files-from-a-github-repository-folder-using-r
library(httr)
library(stringr)
library(dplyr)
#note that there is a default public rate limit; authenticated users get higher rate limit
#didnt set that up here
tryCatch(
expr = {
csheet_data <- readr::read_csv("https://raw.githubusercontent.com/parmsam/R-cheatsheets-explorer/main/csheet_data.csv")
},
error = {
req <- GET("https://api.github.com/repos/rstudio/cheatsheets/git/trees/master?recursive=1")
stop_for_status(req)
filelist <- unlist(lapply(content(req)$tree, "[", "path"), use.names = F)

cheatsheet_list <- filelist[filelist %>% str_detect("pdf")]

base_url <- "https://github.com/rstudio/cheatsheets/raw/master/"

base_gh_url <-"https://github.com/rstudio/cheatsheets/blob/master/"

csheet_data <- cheatsheet_list %>%
as_data_frame() %>%
rename(`PDF Links` = value)

# readr::write_csv(csheet_data, "csheet_data.csv")
})

csheet_data2 <- csheet_data %>%
cbind(Tags = cheatsheet_list) %>%
mutate(Tags = str_replace_all(Tags, "/",", ")) %>%
mutate(Tags = str_replace_all(Tags, "([a-z])([A-Z])","\\1 \\2")) %>%
mutate(Tags = str_replace_all(Tags, "[-_]"," ")) %>%
mutate(Tags = str_remove_all(Tags, "\\.pdf")) %>%
mutate(`PDF Links` = str_c(base_url, cheatsheet_list)) %>%
mutate(`Github Links` = str_c(base_gh_url, cheatsheet_list)) %>%
# mutate(`Embedded` = str_c('<iframe src=', `Github Links`, '></iframe>')) %>%
mutate(`Github Links` = str_c("<a href='", `Github Links`, "'>Preview here</a>")) %>%
mutate(`PDF Links` = str_c("<a href='", `PDF Links`, "'>Download here</a>"))

csheet_data3 <- csheet_data2 %>% mutate(Language = str_extract(Tags, "translations, .*,") ) %>%
mutate(Language = str_remove(Language, "translations, ")) %>%
mutate(Language = str_remove(Language, "|(, [a-zA-Z ,]*)")) %>%
mutate(Language = ifelse(is.na(Language), "english", str_remove(Language, ",") )) %>%
relocate(Tags, Language, `PDF Title`)

csheet_data3},
escape = FALSE)

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store