Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
2bd4b4b
Set years and analysis_id
agnepagne Oct 5, 2025
9e127c8
Get rid of pool
agnepagne Oct 5, 2025
9e1f799
Delete man entry for pool
agnepagne Oct 5, 2025
37fc4e8
Add reordering for SDG table
agnepagne Oct 5, 2025
4b6a112
New package data
agnepagne Oct 5, 2025
9095b6b
Docs
agnepagne Oct 5, 2025
f4d5328
Fix doc mismatch
agnepagne Oct 5, 2025
1ff58e0
Move graphs to top of page in Publication summary
agnepagne Oct 10, 2025
a103be9
Move all text on summary page to the left and include a graph over pu…
agnepagne Oct 10, 2025
772efbc
Moving figs in journal overview
fileunderwater Oct 22, 2025
ff10f8e
Move journal figs in scopus tab
fileunderwater Oct 22, 2025
be9e617
test of plotly on overview
fileunderwater Oct 22, 2025
cb4fc97
pushing plotly tests on overview and cf
fileunderwater Oct 23, 2025
b91100f
fix plotly interactions
fileunderwater Nov 3, 2025
1f4feee
adding plotly wrapping function
fileunderwater Nov 3, 2025
6fcc5b9
basic plotly in all graphs
fileunderwater Nov 3, 2025
9b4a35b
fix some R CMD CHECK warnings
mskyttner Nov 4, 2025
9812a97
removed jcf-tests for plotly
fileunderwater Nov 5, 2025
5438683
Fix div/sizing problem in scopus-citations
fileunderwater Nov 5, 2025
d455498
Adjust plotlyfication
fileunderwater Nov 5, 2025
e388705
Fixing formats of hovertiles in plotly
fileunderwater Nov 5, 2025
6782084
final fixes to plotly version of graphs + som layout changes
fileunderwater Nov 6, 2025
f6c11c3
Fix hover counts for stacked graphs
fileunderwater Nov 6, 2025
7643e2c
Fix year span in abm_config
agnepagne Nov 7, 2025
855013b
Public ABM data for 2025
agnepagne Nov 7, 2025
9df0ff8
Change deprecated size to linewidth in ggplot lines
agnepagne Nov 7, 2025
51dc027
Docs
agnepagne Nov 7, 2025
47afedd
Fix Diva-types in WoS coverage graph
fileunderwater Nov 7, 2025
8198c9e
Merge branch 'abm-2025' of https://github.com/KTH-Library/bibliomatri…
fileunderwater Nov 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ Meta
/inst/shiny-apps/abm/www/cache/*.html
*.DS_Store
/Meta/
bibliomatrix.Rproj
10 changes: 5 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ Description: Shared functionality for working with bibliometric analytics. This
License: file LICENSE
Encoding: UTF-8
LazyData: true
Depends: R (>= 2.10)
Depends: R (>= 4.1.0)
Suggests:
testthat (>= 2.1.0),
bench
RoxygenNote: 7.3.2
RoxygenNote: 7.3.3
Imports:
DBI (>= 1.0.0),
RSQLite (>= 2.1.2),
Expand All @@ -34,7 +34,6 @@ Imports:
tidyr (>= 1.0.0),
tibble (>= 2.1.3),
curl (>= 4.2),
pool (>= 0.1.4),
magrittr (>= 1.5),
readr (>= 1.3.1),
callr (>= 3.3.2),
Expand Down Expand Up @@ -78,7 +77,8 @@ Imports:
openxlsx
Remotes:
KTH-Library/kthapi,
KTH-Library/ktheme
URL: https://github.com/KTH-Library/bibliomatrix
KTH-Library/ktheme,
hrbrmstr/waffle
URL: https://github.com/KTH-Library/bibliomatrix, https://kth-library.github.io/bibliomatrix
BugReports: https://github.com/KTH-Library/bibliomatrix/issues
VignetteBuilder: knitr
4 changes: 1 addition & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export(abm_graph_top20)
export(abm_graph_top20_plotly)
export(abm_graph_wos_coverage)
export(abm_graph_wos_coverage_plotly)
export(abm_plotlyfy)
export(abm_private_data)
export(abm_public_data)
export(abm_publications)
Expand Down Expand Up @@ -135,7 +136,6 @@ export(nowrap_html)
export(nowrap_hyphen_sub)
export(palette_kth)
export(palette_kth_info)
export(pool_bib)
export(prerender)
export(prerender_cache_location)
export(prerender_cache_sync)
Expand Down Expand Up @@ -163,7 +163,6 @@ import(odbc)
import(openxlsx)
import(patchwork)
import(plotrix)
import(pool)
import(progress)
import(purrr)
import(rappdirs)
Expand Down Expand Up @@ -228,7 +227,6 @@ importFrom(plotly,config)
importFrom(plotly,ggplotly)
importFrom(plotly,layout)
importFrom(plotly,plot_ly)
importFrom(pool,poolClose)
importFrom(progress,progress_bar)
importFrom(purrr,map)
importFrom(purrr,map_chr)
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# bibliomatrix 1.10

* This version includes changes listed here: <https://github.com/KTH-Library/bibliomatrix/milestone/15s?closed=1>

# bibliomatrix 1.9

* This version includes changes listed here: <https://github.com/KTH-Library/bibliomatrix/milestone/14s?closed=1>
Expand Down
77 changes: 43 additions & 34 deletions R/abm.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
abm_config <- function() {

# this can later be expanded with more relevant defaults
y_start <- 2014
y_stop <- 2023
analysisId <- 11
current_year <- as.integer(format(Sys.Date(), "%Y"))
y_start <- current_year - 10
y_stop <- current_year - 1
analysisId <- 17

if (Sys.getenv("ABM_START_YEAR") != "")
y_start <- Sys.getenv("ABM_START_YEAR")
Expand Down Expand Up @@ -943,7 +944,7 @@ abm_publications <- function(data, analysis_start = abm_config()$start_year, ana
#' "units" with a named list of results (set of tibbles for each of the units),
#' "pt_ordning" for DiVA publication type sort order
#' and analysis_date for the date of data extraction
#' @importFrom pool poolClose
#' @importFrom DBI dbDisconnect
#' @importFrom readr write_rds
#' @importFrom purrr map
#' @importFrom stats setNames
Expand Down Expand Up @@ -981,7 +982,7 @@ abm_public_data <- function(overwrite_cache = FALSE) {
if (file.exists(cache_location) & !overwrite_cache)
return (readr::read_rds(cache_location))

db <- pool_bib()
db <- con_bib()

# retrieve unit codes
units_table <-
Expand Down Expand Up @@ -1048,7 +1049,7 @@ abm_public_data <- function(overwrite_cache = FALSE) {
res <- map(units, unit_tables)
res <- setNames(res, units)

poolClose(db)
dbDisconnect(db)

out <- list("meta" = units_table,
"units" = res,
Expand All @@ -1071,7 +1072,7 @@ abm_public_data <- function(overwrite_cache = FALSE) {
#' and "units" with a named list of results (set of 5 different tibbles for
#' the tables and also the publication list).
#' @importFrom stats setNames
#' @importFrom pool poolClose
#' @importFrom DBI dbDisconnect
#' @export
#' @examples
#' \dontrun{
Expand All @@ -1091,7 +1092,7 @@ abm_private_data <- function(unit_code) {
if (missing(unit_code))
stop("Please provide a kthid to be used as unit_code.")

db <- pool_bib()
db <- con_bib()

# retrieve unit codes
units_table <-
Expand Down Expand Up @@ -1128,7 +1129,7 @@ abm_private_data <- function(unit_code) {
res <- list(unit_tables(unit_code))
res <- setNames(res, unit_code)

poolClose(db)
dbDisconnect(db)

out <- list("meta" = units_table, "units" = res)

Expand All @@ -1143,25 +1144,31 @@ abm_private_data <- function(unit_code) {
#' @importFrom stats reorder
#' @export
abm_graph_diva <- function(df) {

`Publication type` <- NULL

df_diva_long <- df |>
select(-"P_frac", -"WoS_coverage", -"Scopus_coverage") |>
gather("year", "value", -Publication_Type_DiVA) |>
left_join(get_pubtype_order(), by = c("Publication_Type_DiVA" = "diva_publication_type"))
left_join(get_pubtype_order(), by = c("Publication_Type_DiVA" = "diva_publication_type")) |>
mutate(`Publication type` = reorder(Publication_Type_DiVA, desc(pt_ordning)))

colvals <- unname(palette_kth_neo(13, type = "qual"))
names(colvals) <- abm_public_kth$pubtype_order |> filter(pt_ordning <= 13) |> pull(diva_publication_type)

ggplot(data = df_diva_long,
aes(x = year)) +
geom_bar(aes(weight = value, fill = reorder(Publication_Type_DiVA, desc(pt_ordning)))) +
aes(x = year, text = paste(round(value,1)), #"<b>Publications:</b>",
value2 = round(df_diva_long$value,1),
value = value)) +
geom_bar(aes(weight = value, fill = `Publication type`)) +
labs(x = "Publication year",
y = "Number of publications (fractional)",
fill = NULL) +
scale_fill_manual(values = colvals) +
theme_kth_neo() +
theme(axis.title.y = element_text(vjust = 2.5),
legend.position = "right",
legend.y.intersp = 0.5,
panel.grid.major.x = element_blank(),
panel.grid.minor.y = element_blank())
}
Expand All @@ -1182,11 +1189,11 @@ abm_graph_wos_coverage <- function(df) {
df <- df |>
left_join(get_pubtype_order(), by = c("Publication_Type_DiVA" = "diva_publication_type")) |>
filter(WoS_coverage != 0) |>
mutate(Publication_Type_DiVA = gsub(" \\(", "\n(", gsub(", ", ",\n", Publication_Type_DiVA)))
mutate(Publication_Type_DiVA_alt = gsub(" \\(", "\n(", gsub(", ", ",\n", Publication_Type_DiVA)))

ggplot(data = df,
aes(x = reorder(Publication_Type_DiVA, WoS_coverage),
text = paste('coverage:', sprintf("%.1f", 100 * WoS_coverage), '%')
aes(x = reorder(Publication_Type_DiVA_alt, WoS_coverage),
text = paste(Publication_Type_DiVA) #'coverage:', sprintf("%.1f", 100 * WoS_coverage), '%'
)) +
geom_bar(aes(weight = WoS_coverage), fill = kth_cols["blue"]) +
xlab(NULL) +
Expand Down Expand Up @@ -1217,11 +1224,11 @@ abm_graph_cf <- function(df){
geom_point(color = kth_cols["blue1"], size = 3) +
#geom_line(color = kth_cols["blue2"], size = .8) +
#geom_ma(ma_fun = SMA, n = 3, size = 3, color = kth_cols["blue2"]) +
geom_line(aes(y=ma3), color = kth_cols["blue2"], size = 1) +
geom_line(aes(y=ma3), color = kth_cols["blue2"], linewidth = 1) +
xlab("Publication year") +
ylab("Average Cf") +
ylim(0, ymax) +
geom_hline(yintercept = 1.0, color = kth_cols["blue3"], size = .8) +
geom_hline(yintercept = 1.0, color = kth_cols["blue3"], linewidth = .8) +
theme_kth_neo() +
theme(axis.title.y = element_text(vjust = 2.5),
panel.grid.major.x = element_blank(),
Expand All @@ -1242,7 +1249,7 @@ abm_graph_top10 <- function(df){
ggplot(data = df |> filter(!Publication_Year == "Total"),
aes(x = Publication_Year, y = top10_share, group=1)) +
geom_point(color = kth_cols["blue1"], size = 3) +
geom_line(color = kth_cols["blue2"], size = .8) +
geom_line(color = kth_cols["blue2"], linewidth = .8) +
xlab("Publication year") +
ylab("Share Top 10%") +
geom_hline(yintercept = 0.1, color = kth_cols["blue3"], size = .8) +
Expand All @@ -1266,11 +1273,11 @@ abm_graph_jcf <- function(df){
ggplot(data = df |> filter(!Publication_Year == "Total"),
aes(x = Publication_Year, y = jcf, group=1)) +
geom_point(color = kth_cols["blue1"], size = 3) +
geom_line(color = kth_cols["blue2"], size = .8) +
geom_line(color = kth_cols["blue2"], linewidth = .8) +
xlab("Publication year") +
ylab("Average Journal Cf") +
ylim(0, ymax) +
geom_hline(yintercept = 1.0, color = kth_cols["blue3"], size = .8) +
geom_hline(yintercept = 1.0, color = kth_cols["blue3"], linewidth = .8) +
theme_kth_neo() +
theme(axis.title.y = element_text(vjust = 2.5),
panel.grid.major.x = element_blank(),
Expand All @@ -1291,7 +1298,7 @@ abm_graph_top20 <- function(df){
ggplot(data = df |> filter(!Publication_Year == "Total"),
aes(x = Publication_Year, y = top20_share, group=1)) +
geom_point(color = kth_cols["blue1"], size = 3) +
geom_line(color = kth_cols["blue2"], size = .8) +
geom_line(color = kth_cols["blue2"], linewidth = .8) +
xlab("Publication year") +
ylab("Share Journal Top 20%") +
geom_hline(yintercept = 0.2, color = kth_cols["blue3"], size = .8) +
Expand Down Expand Up @@ -1319,7 +1326,7 @@ abm_graph_copub <- function(df){

ggplot(data = df_copub_long,
aes(x = Publication_Year, y = value, group = `Co-publication:`)) +
geom_line(aes(color = `Co-publication:`), size = .8) +
geom_line(aes(color = `Co-publication:`), linewidth = .8) +
geom_point(aes(color = `Co-publication:`), size = 3) +
xlab("Publication year") +
ylab("Share of publications") +
Expand Down Expand Up @@ -1378,7 +1385,7 @@ abm_graph_oa_lines <- function(df){
scale_size_identity() +
scale_alpha_identity() +
scale_color_manual(
name = 'OA type',
#name = 'OA type',
values = unpaywall) +
scale_x_continuous(breaks = xbreaks) +
scale_y_continuous(breaks = ybreaks,
Expand Down Expand Up @@ -1542,9 +1549,11 @@ abm_graph_oadata_stackedarea <- function(df){
xymelt <- melt(df_oa_graphdata, id.vars = "Publication_Year") |>
rename("OA type:"=variable)

ggplot(xymelt, aes(x = Publication_Year, y = value, fill = `OA type:`, group = `OA type:`)) +
ggplot(xymelt, aes(x = Publication_Year, y = value, fill = `OA type:`, group = `OA type:`,
text = paste0(round(value)))) +
scale_fill_manual(values = unpaywall_cols) +
geom_area() +
geom_area(stat = "identity") +
#geom_polygon() +
#TODO: geom_line() + ?
xlab("Publication year") +
ylab("Number of publications") +
Expand All @@ -1568,7 +1577,7 @@ abm_graph_scop_normcit <- function(df){
ggplot(data = df |> filter(!Publication_Year == "Total"),
aes(x = Publication_Year, y = fwci_x, group=1)) +
geom_point(color = kth_cols["blue1"], size = 3) +
geom_line(color = kth_cols["blue2"], size = .8) +
geom_line(color = kth_cols["blue2"], linewidth = .8) +
xlab("Publication years") +
ylab("Average FWCI") +
ylim(0, ymax) +
Expand All @@ -1593,10 +1602,10 @@ abm_graph_scop_top10 <- function(df){
ggplot(data = df |> filter(!Publication_Year == "Total"),
aes(x = Publication_Year, y = top10_share, group=1)) +
geom_point(color = kth_cols["blue1"], size = 3) +
geom_line(color = kth_cols["blue2"], size = .8) +
geom_line(color = kth_cols["blue2"], linewidth = .8) +
xlab("Publication years") +
ylab("Share Top 10%") +
geom_hline(yintercept = 0.1, color = kth_cols["blue3"], size = .8) +
geom_hline(yintercept = 0.1, color = kth_cols["blue3"], linewidth = .8) +
scale_y_continuous(labels = percent_format(accuracy = 5L), limits = c(0, ymax)) +
theme_kth_neo() +
theme(axis.title.y = element_text(vjust = 2.5),
Expand All @@ -1617,11 +1626,11 @@ abm_graph_scop_snip <- function(df){
ggplot(data = df |> filter(!Publication_Year == "Total"),
aes(x = Publication_Year, y = avg_snip, group=1)) +
geom_point(color = kth_cols["blue1"], size = 3) +
geom_line(color = kth_cols["blue2"], size = .8) +
geom_line(color = kth_cols["blue2"], linewidth = .8) +
xlab("Publication years") +
ylab("Average SNIP") +
ylim(0, ymax) +
geom_hline(yintercept = 1.0, color = kth_cols["blue3"], size = .8) +
geom_hline(yintercept = 1.0, color = kth_cols["blue3"], linewidth = .8) +
theme_kth_neo() +
theme(axis.title.y = element_text(vjust = 2.5),
panel.grid.major.x = element_blank(),
Expand All @@ -1642,10 +1651,10 @@ abm_graph_scop_top20 <- function(df){
ggplot(data = df |> filter(!Publication_Year == "Total"),
aes(x = Publication_Year, y = top20_share, group=1)) +
geom_point(color = kth_cols["blue1"], size = 3) +
geom_line(color = kth_cols["blue2"], size = .8) +
geom_line(color = kth_cols["blue2"], linewidth = .8) +
xlab("Publication years") +
ylab("Share Journal Top 20%") +
geom_hline(yintercept = 0.2, color = kth_cols["blue3"], size = .8) +
geom_hline(yintercept = 0.2, color = kth_cols["blue3"], linewidth = .8) +
scale_y_continuous(labels = percent_format(accuracy = 5L), limits = c(0, ymax)) +
theme_kth_neo() +
theme(axis.title.y = element_text(vjust = 2.5),
Expand All @@ -1670,7 +1679,7 @@ abm_graph_scop_copub <- function(df){

ggplot(data = df_copub_long,
aes(x = Publication_Year, y = value, group = `Co-publication:`)) +
geom_line(aes(color = `Co-publication:`), size = .8) +
geom_line(aes(color = `Co-publication:`), linewidth = .8) +
geom_point(aes(color = `Co-publication:`), size = 3) +
xlab("Publication year") +
ylab("Share of publications") +
Expand All @@ -1697,7 +1706,7 @@ abm_graph_scop_copub <- function(df){
#' @import DBI dplyr tidyr purrr
#' @export
abm_copub_data <- function(con = con_bib(), unit_code, analysis_start = abm_config()$start_year, analysis_stop = abm_config()$stop_year) {
oa_data <- abm_data(con = con, unit_code = unit_code) |>
oa_data <- abm_data(con = con, unit_code = unit_code, analysisId = abm_config()$analysis_id) |>
rename("UT" = "WebofScience_ID") |>
left_join(con |> tbl("Bestresaddr_KTH"), by = "UT") |> #by = c("WebofScience_ID" = "UT")
filter(!is.na(UT)) |>
Expand Down
Loading