Skip to content

Commit 0a8ac2d

Browse files
authored
Merge pull request #477 from massimoaria/develop
CRAN submission 4.3.0
2 parents f9c6613 + cae6547 commit 0a8ac2d

17 files changed

+90
-36
lines changed

DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: bibliometrix
22
Type: Package
33
Title: Comprehensive Science Mapping Analysis
4-
Version: 4.2.4
4+
Version: 4.3.0
55
Authors@R: c(
66
person(given = "Massimo",
77
family = "Aria",

NEWS

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
bibliometrix v4.2.4 (Release date: 2024-06-20)
1+
bibliometrix v4.3.0 (Release date: 2024-06-30)
22

33
Features:
44
* Improved the function mergeDbSources()

R/biblioNetwork.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
#' @param shortlabel is logical. IF TRUE, reference labels are stored in a short format. Default is \code{shortlabel=TRUE}.
4646
#' @param remove.terms is a character vector. It contains a list of additional terms to delete from the documents before term extraction. The default is \code{remove.terms = NULL}.
4747
#' @param synonyms is a character vector. Each element contains a list of synonyms, separated by ";", that will be merged into a single term (the first word contained in the vector element). The default is \code{synonyms = NULL}.
48-
#' @return It is a squared network matrix. It is an object of class \code{dgMatrix} of the package \code{\link{Matrix}}.
48+
#' @return It is a squared network matrix. It is an object of class \code{dgMatrix} of the package \code{Matrix}.
4949
#' @examples
5050
#' # EXAMPLE 1: Authors collaboration network
5151
#'

R/cocMatrix.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ utils::globalVariables(c("item","SR"))
2929
#' @param type indicates the output format of co-occurrences: \tabular{lll}{
3030
#' \code{type = "matrix"} \tab \tab produces an object of class
3131
#' \code{matrix}\cr \code{type = "sparse"} \tab \tab produces an object of
32-
#' class \code{dgMatrix} of the package \code{\link{Matrix}}. "sparse"
32+
#' class \code{dgMatrix} of the package \code{Matrix}. "sparse"
3333
#' argument generates a compact representation of the matrix.}
3434
#' @param n is an integer. It indicates the number of items to select. If \code{N = NULL}, all items are selected.
3535
#' @param sep is the field separator character. This character separates strings in each

R/collabByRegionPlot.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ utils::globalVariables(c("countries","continent"))
4444
#' @return It is a list containing the following elements:
4545
#' \tabular{lll}{
4646
#' \code{graph} \tab \tab a network object of the class \code{igraph}\cr
47-
#' \code{cluster_obj} \tab \tab a \code{\link{communities}} object of the package \code{igraph}\cr
47+
#' \code{cluster_obj} \tab \tab a \code{communities} object of the package \code{igraph}\cr
4848
#' \code{cluster_res} \tab \tab a data frame with main results of clustering procedure.\cr}
4949
#'
5050
#'

R/csvOA2df.R

+53-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
utils::globalVariables(c("all_of", "corr", "DI", "C1","id_oa","RP","UN","AU_ID","corresponding_author_ids"))
1+
utils::globalVariables(c("all_of", "corr", "DI", "C1","id_oa","RP","UN","AU_ID","corresponding_author_ids", "References"))
22

33
csvOA2df <- function(file){
44
options(readr.num_columns = 0)
@@ -28,7 +28,7 @@ csvOA2df <- function(file){
2828
# recode as numeric
2929
DATA$TC <- as.numeric(DATA$TC)
3030
DATA$PY <- as.numeric(DATA$PY)
31-
DATA$relevance_score <- as.numeric(DATA$relevance_score)
31+
#DATA$relevance_score <- as.numeric(DATA$relevance_score)
3232

3333
# replace | with ;
3434
DATA <- DATA %>%
@@ -48,21 +48,35 @@ csvOA2df <- function(file){
4848
AFF <- DATA %>%
4949
select(id_oa, starts_with("authorships_raw_affiliation_strings_"))
5050

51-
colId <- c(-1,parse_number(colnames(AFF)[-1]))
52-
53-
DATA <- AFF[order(colId)] %>%
54-
unite(., C1, starts_with("authorships_raw_affiliation_strings_"), sep=";") %>%
55-
mutate(C1 = gsub("NA","",C1),
56-
C1 = TrimMult(C1,char=";")) %>%
57-
bind_cols(DATA %>%
58-
select(-"id_oa", -starts_with("authorships_raw_affiliation_strings_")))
59-
51+
if(ncol(AFF)>1){
52+
colId <- c(-1,parse_number(colnames(AFF)[-1]))
53+
54+
DATA <- AFF[order(colId)] %>%
55+
unite(., C1, starts_with("authorships_raw_affiliation_strings_"), sep=";") %>%
56+
mutate(C1 = gsub("NA","",C1),
57+
C1 = TrimMult(C1,char=";")) %>%
58+
bind_cols(DATA %>%
59+
select(-"id_oa", -starts_with("authorships_raw_affiliation_strings_")))
60+
} else {
61+
AFF <- lapply(stri_extract_all_regex(DATA$authorships.raw_affiliation_strings, "\\[([^\\]]+)\\]"), function(l){
62+
gsub("\\['|'\\]","",l)
63+
})
64+
65+
AFF <- data.frame(id_oa=rep(DATA$id_oa, lengths(AFF)), C1 = unlist(AFF)) %>%
66+
group_by(id_oa) %>%
67+
summarize(C1 = paste(C1,collapse=";"))
68+
DATA <- DATA %>%
69+
left_join(AFF, by = "id_oa")
70+
DATA$C1[is.na(DATA$C1)] <- ""
71+
}
72+
6073
DATA$C1 <- gsub("https://", "", DATA$C1)
6174

6275
# country string
6376
CO <- DATA %>%
6477
select(id_oa, starts_with("authorships_countries_"))
6578

79+
if(ncol(CO)>1){
6680
colId <- c(-1,parse_number(colnames(CO)[-1]))
6781

6882
DATA <- CO[order(colId)] %>%
@@ -71,12 +85,32 @@ csvOA2df <- function(file){
7185
AU_CO = TrimMult(AU_CO,char=";")) %>%
7286
bind_cols(DATA %>%
7387
select(-"id_oa", -starts_with("authorships_countries_")))
88+
} else {
89+
CO <- lapply(stri_extract_all_regex(DATA$authorships.countries, "\\[([^\\]]+)\\]"), function(l){
90+
gsub("\\['|'\\]","",l)
91+
})
92+
93+
CO <- data.frame(id_oa=rep(DATA$id_oa, lengths(CO)), AU_CO = unlist(CO)) %>%
94+
group_by(id_oa) %>%
95+
summarize(AU_CO = gsub("'","",paste(AU_CO,collapse=";")))
96+
DATA <- DATA %>%
97+
left_join(CO, by = "id_oa")
98+
DATA$AU_CO[is.na(DATA$AU_CO)] <- ""
99+
}
100+
74101

75102
## corresponding author
76103
DATA <- DATA %>%
77104
mutate(AU1_ID = gsub(";.*", "", corresponding_author_ids))
78105
UN <- strsplit(DATA$C1,";")
79-
corresp <- strsplit(DATA$authorships_is_corresponding,";")
106+
if ("authorships_is_corresponding" %in% names(DATA)){
107+
corresp <- strsplit(tolower(DATA$authorships_is_corresponding),";")
108+
} else {
109+
corresp <- strsplit(tolower(DATA$authorships.is_corresponding),";")
110+
}
111+
112+
113+
80114
df_UN <- data.frame(UN=unlist(UN), id_oa=rep(DATA$id_oa,lengths(UN))) %>%
81115
group_by(id_oa) %>%
82116
mutate(n=row_number())
@@ -120,6 +154,7 @@ csvOA2df <- function(file){
120154
mutate(across(all_of(label), toupper),
121155
DI = gsub("https://doi.org/","",DI),
122156
DI = ifelse(DI == "null",NA,DI))
157+
DATA$SO <- toupper(DATA$SO)
123158

124159
return(DATA)
125160
}
@@ -130,14 +165,18 @@ relabelling_OA <- function(DATA){
130165
label[label %in% "id"] <- "id_oa"
131166
label[label %in% "display_name"] <- "TI"
132167
label[label %in% "primary_location_display_name"] <- "SO"
168+
label[label %in% "locations.source.display_name"] <- "SO"
133169
label[label %in% "primary_location_id"] <- "SO_ID"
170+
label[label %in% "locations.source.id"] <- "SO_ID"
134171
label[label %in% "primary_location_host_organization"] <- "PU"
135172
label[label %in% "primary_location_issns"] <- "ISSN"
136173
label[label %in% "primary_location_issn_l"] <- "ISSN_I"
137174
label[label %in% "primary_location_landing_page_url"] <- "URL"
138175
label[label %in% "primary_location_pdf_url"] <- "URL_PDF"
139176
label[label %in% "author_ids"] <- "AU_ID"
177+
label[label %in% "authorships.author.id"] <- "AU_ID"
140178
label[label %in% "author_names"] <- "AU"
179+
label[label %in% "authorships.author.display_name"] <- "AU"
141180
label[label %in% "author_orcids"] <- "OI"
142181
label[label %in% "author_institution_names"] <- "C3"
143182
label[label %in% "cited_by_count"] <- "TC"
@@ -147,6 +186,7 @@ relabelling_OA <- function(DATA){
147186
label[label %in% "biblio_volume"] <- "VL"
148187
label[label %in% "referenced_works" ] <- "CR"
149188
label[label %in% "keywords_display_name"] <- "DE"
189+
label[label %in% "keywords.display_name"] <- "DE"
150190
label[label %in% "abstract"] <- "AB"
151191
label[label %in% "concepts_display_name"] <- "CONCEPTS"
152192
label[label %in% "topics_display_name"] <- "TOPICS"
@@ -165,4 +205,4 @@ relabelling_OA <- function(DATA){
165205
TrimMult <- function(x, char=" ") {
166206
return(gsub(paste0("^", char, "*|(?<=", char, ")", char, "|", char, "*$"),
167207
"", x, perl=T))
168-
}
208+
}

R/networkPlot.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ utils::globalVariables(c("degree"))
4747
#' @return It is a list containing the following elements:
4848
#' \tabular{lll}{
4949
#' \code{graph} \tab \tab a network object of the class \code{igraph}\cr
50-
#' \code{cluster_obj} \tab \tab a \code{\link{communities}} object of the package \code{igraph}\cr
50+
#' \code{cluster_obj} \tab \tab a \code{communities} object of the package \code{igraph}\cr
5151
#' \code{cluster_res} \tab \tab a data frame with main results of clustering procedure.\cr}
5252
#'
5353
#'

R/networkStat.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#' @return It is a list containing the following elements:
1111
#' \tabular{lll}{
1212
#' \code{graph} \tab \tab a network object of the class \code{igraph}\cr
13-
#' \code{network} \tab \tab a \code{\link{communities}} a list with the main statistics of the network\cr
13+
#' \code{network} \tab \tab a \code{communities} a list with the main statistics of the network\cr
1414
#' \code{vertex} \tab \tab a data frame with the main measures of centrality and prestige of vertices.\cr}
1515
#'
1616
#'

R/rpys.R

+10-6
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,16 @@ logo <- grid::rasterGrob(logo,interpolate = TRUE)
108108
x <- c(min(RPYS$Year),min(RPYS$Year)+diff(range(RPYS$Year))*0.125)+1
109109
y <- c(min(c(RPYS$Citations,RPYS$diffMedian)),min(c(RPYS$Citations,RPYS$diffMedian))+diff(range(c(RPYS$Citations,RPYS$diffMedian)))*0.125)*1.05
110110

111+
RPYS <- RPYS %>%
112+
left_join(CR %>%
113+
group_by(citedYears) %>%
114+
slice_max(order_by = Freq, n=3, with_ties = FALSE) %>%
115+
summarize(References = paste(firstup(Reference),collapse="\n")),
116+
by=c("Year" = "citedYears"))
111117

112118

113-
g=ggplot(RPYS, aes(x=Year ,y=Citations,text=paste("Year: ",Year,"\nN. of References: ",Citations)))+
119+
g=ggplot(RPYS, aes(x=Year ,y=Citations,text=paste("Year: ",Year," - Total Citations: ",Citations,"\nTop 3 References:\n",References)))+
114120
geom_line(aes(group="NA")) +
115-
#geom_area(aes(group="NA"),fill = 'grey90', alpha = .5) +
116-
#geom_hline(aes(yintercept=0, color = 'grey'))+
117121
geom_line(aes(x=Year,y=diffMedian, color="firebrick", group="NA"))+
118122
labs(x = 'Year'
119123
, y = 'Cited References'
@@ -131,8 +135,8 @@ g=ggplot(RPYS, aes(x=Year ,y=Citations,text=paste("Year: ",Year,"\nN. of Referen
131135
,axis.title.y = element_text(vjust = 1, angle = 90)
132136
,axis.title.x = element_text(hjust = 0.95, angle = 0)
133137
,axis.text.x = element_text(size=8,angle = 90)
134-
,axis.line.x = element_line(color="black", size=0.5)
135-
,axis.line.y = element_line(color="black", size=0.5)
138+
,axis.line.x = element_line(color="black", linewidth=0.5)
139+
,axis.line.y = element_line(color="black", linewidth=0.5)
136140
) + annotation_custom(logo, xmin = x[1], xmax = x[2], ymin = y[1], ymax = y[2])
137141

138142
if (isTRUE(graph)){plot(g)}
@@ -141,7 +145,7 @@ g=ggplot(RPYS, aes(x=Year ,y=Citations,text=paste("Year: ",Year,"\nN. of Referen
141145
rename(Year = citedYears) %>%
142146
ungroup()
143147
result=list(spectroscopy=g,
144-
rpysTable=RPYS,
148+
rpysTable=RPYS %>% select(-References),
145149
CR=CR %>% mutate(Year = as.character(Year)),
146150
df=df)
147151
return(result)

R/zzz.R

+7
Original file line numberDiff line numberDiff line change
@@ -737,3 +737,10 @@ colorlist <- function(){
737737
,"#B3B3B3","#A6CEE3","#1F78B4","#B2DF8A","#33A02C","#FB9A99","#E31A1C","#FDBF6F","#FF7F00","#CAB2D6","#6A3D9A","#B15928","#8DD3C7","#BEBADA"
738738
,"#FB8072","#80B1D3","#FDB462","#B3DE69","#D9D9D9","#BC80BD","#CCEBC5")
739739
}
740+
741+
#Initial to upper case
742+
firstup <- function(x) {
743+
x <- tolower(x)
744+
substr(x, 1, 1) <- toupper(substr(x, 1, 1))
745+
x
746+
}

inst/biblioshiny/libraries.R

+6-4
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,17 @@ libraries <- function(){
2424
## Currently "webshot2" 0.1.1 generates empty screenshots on windows 10 for graphics created with visnetwork.
2525
## This workaround installs the previous version 0.1.0 to temporarily fix the problem.
2626
if (!require(webshot2,quietly=TRUE)){
27-
install.packages("https://cran.r-project.org/src/contrib/Archive/webshot2/webshot2_0.1.0.tar.gz",
28-
repos = NULL, type = "source", c("Depends", "Imports"))
27+
install.packages("webshot2")
28+
detach("package:webshot2", unload = TRUE, force=TRUE)
29+
install.packages("https://cran.r-project.org/src/contrib/Archive/webshot2/webshot2_0.1.0.tar.gz",
30+
repos = NULL, type = "source", dependencies=c("Depends", "Imports"))
2931
}else{
3032
pkgs <- installed.packages()[, "Version"]
3133
vers <- pkgs["webshot2"]
3234
if (vers!="0.1.0"){
3335
detach("package:webshot2", unload = TRUE, force=TRUE)
34-
install.packages("https://cran.r-project.org/src/contrib/Archive/webshot2/webshot2_0.1.0.tar.gz",
35-
repos = NULL, type = "source", c("Depends", "Imports"))
36+
install.packages("https://cran.r-project.org/src/contrib/Archive/webshot2/webshot2_0.1.0.tar.gz",
37+
repos = NULL, type = "source", dependencies=c("Depends", "Imports"))
3638
}
3739
}
3840
##

inst/biblioshiny/utils.R

+2-1
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ getFileNameExtension <- function (fn) {
297297
ext
298298
}
299299

300-
#Initial to upper case
300+
# Initial to upper case
301301
firstup <- function(x) {
302302
x <- tolower(x)
303303
substr(x, 1, 1) <- toupper(substr(x, 1, 1))
@@ -2232,6 +2232,7 @@ plot2png <- function(p, filename, zoom = 2, type="vis", tmpdir){
22322232
htmlwidgets::saveWidget(p, file=html_name)
22332233
})
22342234
webshot2::webshot(url = html_name, zoom = zoom, file = filename)#, verbose=FALSE)
2235+
22352236
popUpGeneric(title=NULL, type="success", color=c("#1d8fe1"),
22362237
subtitle=paste0("Plot was saved in the following path: ",filename),
22372238
btn_labels="OK", size="40%")

man/biblioNetwork.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/cocMatrix.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/collabByRegionPlot.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/networkPlot.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/networkStat.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)