Warning: package 'scholar' was built under R version 4.2.3
library(tidyverse)
Warning: package 'tidyverse' was built under R version 4.2.3
Warning: package 'ggplot2' was built under R version 4.2.3
Warning: package 'tibble' was built under R version 4.2.3
Warning: package 'tidyr' was built under R version 4.2.3
Warning: package 'readr' was built under R version 4.2.3
Warning: package 'purrr' was built under R version 4.2.3
Warning: package 'dplyr' was built under R version 4.2.3
Warning: package 'stringr' was built under R version 4.2.3
Warning: package 'forcats' was built under R version 4.2.3
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.1.1 ✔ readr 2.1.4
✔ forcats 1.0.0 ✔ stringr 1.5.0
✔ ggplot2 3.5.0 ✔ tibble 3.2.1
✔ lubridate 1.8.0 ✔ tidyr 1.3.0
✔ purrr 1.0.1
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(glue)
Warning: package 'glue' was built under R version 4.2.3
# based on https://thackl.github.io/automatically-update-publications-with-R-scholar# my google scholar user id from my profile url# https://scholar.google.com/citations?hl=en&user=nNY7GfwAAAAJbracic <-"nNY7GfwAAAAJ"# pull from google and adjusthtml_1 <-get_publications(bracic) %>% as_tibble %>%arrange(desc(year)) %>%mutate(author =str_replace_all(author, "M Bračić", "<b>M Bračić</b>"), # Make the author's name boldjournal =ifelse(year ==2015, str_replace_all(journal, '"', ''), journal), # Remove double quotes from journal if year is 2015number =ifelse(year ==2015, str_replace_all(number, '"', ''), number)# Remove double quotes from number if year is 2015 )# convert to htlm table - the ugly way ;)html_2 <- html_1 %>%split(.$year) %>%map(function(x){ x <- x %>%glue_data('<tr><td width="100%">{author} ({year}) <a href="https://scholar.google.com/scholar?oi=bibs&cluster={cid}&btnI=1&hl=en">{title}</a>, {journal}, {number}</td></tr>') %>%str_replace_all( ",\\s*</td></tr>", "</td></tr>") %>%#remove commas if it is the last characterstr_replace_all("(, ,)", " ") # remove double commas x <-c('<table class="publication-table" border="10px solid blue" cellspacing="0" cellpadding="6" rules="", frame=""><tbody>', x, '</tbody></table>')return(x); }) %>% revhtml_3 <-map2(names(html_2) %>%paste0("<h3>", ., "</h3>"), html_2, c) %>% unlisthtml_4 <-c(paste0('<p style="text-align: center; margin-top: -40px;"><small>Last updated <i>',format(Sys.Date(), format="%B %d, %Y"),'– Pulled automatically from my <a href="https://scholar.google.com/citations?hl=en&user=nNY7GfwAAAAJ">Google Scholar profile</a>.</p>'), html_3)# write the html list to a filewriteLines(html_4, "publications/publication_list.html")