Skip to content

Commit

Permalink
* Solved the issue related to exclusion of the ggnetwork package from…
Browse files Browse the repository at this point in the history
… CRAN by removing the dependence from the package
  • Loading branch information
massimoaria committed Jul 5, 2021
1 parent bcaf40d commit 339365b
Show file tree
Hide file tree
Showing 9 changed files with 384 additions and 80 deletions.
1 change: 0 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ Imports: stats,
factoextra,
FactoMineR,
forcats,
ggnetwork,
ggplot2,
ggrepel,
igraph,
Expand Down
5 changes: 4 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ export(trimES)
import(bibliometrixData)
import(dimensionsR)
import(forcats)
import(ggnetwork)
import(ggplot2)
import(ggrepel)
import(pubmedR)
Expand Down Expand Up @@ -181,16 +180,19 @@ importFrom(dplyr,as_tibble)
importFrom(dplyr,between)
importFrom(dplyr,cummean)
importFrom(dplyr,desc)
importFrom(dplyr,do)
importFrom(dplyr,group_by)
importFrom(dplyr,if_all)
importFrom(dplyr,inner_join)
importFrom(dplyr,left_join)
importFrom(dplyr,mutate)
importFrom(dplyr,n)
importFrom(dplyr,relocate)
importFrom(dplyr,rename)
importFrom(dplyr,right_join)
importFrom(dplyr,rowwise)
importFrom(dplyr,select)
importFrom(dplyr,slice)
importFrom(dplyr,slice_head)
importFrom(dplyr,slice_tail)
importFrom(dplyr,summarise)
Expand Down Expand Up @@ -296,6 +298,7 @@ importFrom(tidyr,separate)
importFrom(tidyr,spread)
importFrom(tidyr,starts_with)
importFrom(tidyr,unite)
importFrom(tidyr,unnest)
importFrom(utils,adist)
importFrom(utils,capture.output)
importFrom(utils,data)
Expand Down
6 changes: 4 additions & 2 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
bibliometrix v3.1.4 (Release date: ????-??-??)
bibliometrix v3.1.4 (Release date: 2021-07-05)

Changes:
* Added the possibily to calculate all vertex centrality measures setting the argument type="all"
* Solved the issue with extracting cited sources from scopus collections (function metaTagExtraction)
* Solved the issue with extracting cited sources from Scopus collections (function metaTagExtraction)
* Solved the issue related to exclusion of the ggnetwork package from CRAN by removing the dependence from the package


bibliometrix v3.1.3 (Release date: 2021-05-25)

Expand Down
48 changes: 38 additions & 10 deletions R/couplingMap.R
Original file line number Diff line number Diff line change
Expand Up @@ -306,15 +306,43 @@ labeling <- function(M, df_lab, term, n, n.labels, analysis, ngrams){
df <- left_join(df_lab,M, by=c("sources" = "SO" ))
})

clusters <- unique(df$Cluster)
w <- character(length(clusters))


for (i in 1:length(clusters)){
ind <- which(df$Cluster == clusters[i])
tab <- round((tableTag(df[ind,], term)[1:n.labels])/length(ind)*100,1)
w[i]=tolower(paste(names(tab)," ",as.numeric(tab),"%",sep="", collapse="\n"))
}
return(w)
#clusters <- unique(df$Cluster)
#w <- character(length(clusters))

tab_global <- tableTag(df, term)
tab_global <- data.frame(label=names(tab_global),tot=as.numeric(tab_global), n=nrow(M),stringsAsFactors = FALSE)

df <- df %>%
group_by(.data$Cluster) %>%
do(w = best_lab(.data,tab_global, n.labels, term)) %>%
unnest(.data$w) %>%
as.data.frame()

# for (i in 1:length(clusters)){
# ind <- which(df$Cluster == clusters[i])
# tab <- round((tableTag(df[ind,], term)[1:n.labels])/length(ind),1)
# tab <- data.frame(label=names(tab), value=as.numeric(tab),stringsAsFactors = FALSE)
# tab <- tab %>%
# left_join(tab_global, by = "label") %>%
# mutate(freq = .data$value/.data$tot*100)
#
# w[i]=tolower(paste(tab$label," ",round(tab$freq,1),"%",sep="", collapse="\n"))
# }
return(df$w)

}

best_lab <- function(d, tab_global, n.labels, term){
tab <- tableTag(d, term)
tab <- data.frame(label=names(tab), value=as.numeric(tab), stringsAsFactors = FALSE)
tab <- tab %>%
left_join(tab_global, by = "label") %>%
mutate(conf = round(.data$value/.data$tot*100,1),
supp = round(.data$tot/n*100,1),
relevance = round(.data$conf*.data$supp/100,1)) %>%
arrange(desc(.data$relevance)) %>%
slice(1:n.labels)

#tolower(paste(tab$label," Supp ",tab$supp,"% - Conf ", tab$conf,"%", sep="", collapse="\n"))
tolower(paste(tab$label," - Conf ", tab$conf,"%", sep="", collapse="\n"))
}
12 changes: 7 additions & 5 deletions R/histPlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ histPlot<-function(histResults, n=20, size = 5, labelsize = 5, title_as_label =
layout_m$y <- (diff(range(layout_m$x))/diff(range(layout_m$y)))*layout_m$y

################
df_net <- ggnetwork::ggnetwork(bsk.network, layout=as.matrix(layout_m[c("x","y")]), niter=50000, arrow.gap=0)
df_net <- dataFromIgraph(bsk.network, layout=as.matrix(layout_m[c("x","y")]), niter=50000, arrow.gap=0)
df_net$color <- "slategray1"
df_net <- left_join(df_net,layout_m[c("name","color")], by = "name")
names(df_net)[10:11] <- c("color", "color_v")
Expand All @@ -133,22 +133,22 @@ histPlot<-function(histResults, n=20, size = 5, labelsize = 5, title_as_label =
.data$GCS, sep=""))

g <- ggplot(df_net, aes(x = .data$x, y = .data$y, xend = .data$xend, yend = .data$yend, text=.data$text)) +
geom_edges(color = "grey", size=0.4, alpha=0.4) +
geom_nodes(aes(color = .data$color_v), size = size, alpha=0.5) +
geom_network_edges(color = "grey", size=0.4, alpha=0.4) +
geom_network_nodes(aes(color = .data$color_v), size = size, alpha=0.5) +
geom_text(aes(label=.data$id, color=.data$color_v), size=labelsize,
nudge_x = 0,
nudge_y = 0.02,
check_overlap = FALSE,alpha=0.7)+
scale_x_continuous(labels=Ylabel,breaks=Breaks)+
guides(size=FALSE, color=FALSE) +
guides(size="none", color="none") +
theme_minimal()+
theme(legend.position='none', panel.background = element_rect(fill='white', color='white'),
axis.line.y = element_blank(), axis.text.y = element_blank(),axis.ticks.y=element_blank(),
axis.title.y = element_blank(), axis.title.x = element_blank(),
panel.grid.minor.y = element_blank(), panel.grid.major.y = element_blank(),
panel.grid.major.x = element_line(adjustcolor(col="grey", alpha.f = 0.2), linetype = 2, size = 0.5),
panel.grid.minor.x = element_blank(),
axis.text.x=element_text(face="bold", angle = 90, size=labelsize+3)) +
axis.text.x=element_text(face="bold", angle = 90, size=labelsize+4)) +
labs(title = "Historical Direct Citation Network")

### logo coordinates
Expand Down Expand Up @@ -226,3 +226,5 @@ delete.isolates <- function(graph, mode = 'all') {
isolates <- which(degree(graph, mode = mode) == 0) - 1
delete.vertices(graph, names(isolates))
}


Loading

0 comments on commit 339365b

Please sign in to comment.