Skip to content

Commit

Permalink
Added "measure" parameter in plotThematicEvolution
Browse files Browse the repository at this point in the history
  • Loading branch information
massimoaria committed Nov 19, 2018
1 parent 9433a72 commit 60b47ef
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 10 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: bibliometrix
Type: Package
Title: An R-Tool for Comprehensive Science Mapping Analysis
Version: 2.0.2
Date: 2018-11-15
Version: 2.0.3
Date: 2018-11-19
Authors@R: c(person("Massimo", "Aria", email = "[email protected]", role=c("cre","aut")),
person("Corrado", "Cuccurullo", email = "[email protected]", role="aut"))
Description: Tool for quantitative research in scientometrics and bibliometrics.
Expand Down
8 changes: 8 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
bibliometrix v2.0.3 (Release date: 2018-11-19)
==============

New functionality:
* Added "measure" parameter in plotThematicEvolution



bibliometrix v2.0.2 (Release date: 2018-10-26)
==============

Expand Down
11 changes: 10 additions & 1 deletion R/plotThematicEvolution.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#'
#' @param Nodes is a list of nodes obtained by \code{\link{thematicEvolution}} function.
#' @param Edges is a list of edges obtained by \code{\link{thematicEvolution}} function.
#' @param measure is a character. It can be \code{measure=("inclusion","stability")}.
#' @return a sankeyPlot
#'
#'
Expand All @@ -22,8 +23,16 @@
#'
#' @export

plotThematicEvolution<-function(Nodes,Edges){
plotThematicEvolution<-function(Nodes,Edges,measure="inclusion"){

switch(measure,
inclusion={
Edges=Edges[-4]
},
stability={
Edges=Edges[-3]
})
names(Edges)[3]="weight"
networkD3::sankeyNetwork(Links = Edges, Nodes = Nodes, Source = "from", Target = "to",
NodeID = "name", Value = "weight", width = 900, fontSize = 12,
nodeWidth = 30, NodeGroup = "group",LinkGroup = "group")
Expand Down
11 changes: 7 additions & 4 deletions R/thematicEvolution.R
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ thematicEvolution <- function(M, field="ID", years,n=250,minFreq=2){
CL1=unique(res1$clusters$label)
CL2=unique(res2$clusters$label)

Inc=data.frame(CL1=NA,CL2=NA,Inc_index=NA,Words="NA",Occ=NA,Tot=NA,Inc_Weighted=NA, stringsAsFactors = FALSE)
Inc=data.frame(CL1=NA,CL2=NA,Inc_index=NA,Words="NA",Occ=NA,Tot=NA,Inc_Weighted=NA, Tot_CL1=NA,Tot_CL2=NA, Stability=NA, stringsAsFactors = FALSE)
cont=0

for (ii in 1:length(CL1)){
Expand All @@ -129,6 +129,9 @@ thematicEvolution <- function(M, field="ID", years,n=250,minFreq=2){
Inc[cont,5]=si
Inc[cont,6]=s1
Inc[cont,7]=si/s1
Inc[cont,8]=length(w1)
Inc[cont,9]=length(w2)
Inc[cont,10]=length(wi)/(length(w1)+length(w2)-length(wi))


}
Expand All @@ -146,13 +149,13 @@ thematicEvolution <- function(M, field="ID", years,n=250,minFreq=2){
}

### sankey plot data
edges = INC[,c(1,2,3)]
edges = INC[,c(1,2,3,10)]
edges=edges[edges[,3]>0,]
nodes = data.frame("name"=unique(c(edges$CL1,edges$CL2)),stringsAsFactors = FALSE)
nodes$group=nodes$name

cont=0
edges[,4]=edges[,1]
edges[,5]=edges[,1]
for (i in nodes$name){

ind=which(edges[,1]==i)
Expand All @@ -162,7 +165,7 @@ thematicEvolution <- function(M, field="ID", years,n=250,minFreq=2){
cont=cont+1
}

names(edges)=c("from","to","weight","group")
names(edges)=c("from","to","Inclusion","Stability","group")
edges$from=as.numeric(edges$from)
edges$to=as.numeric(edges$to)

Expand Down
4 changes: 2 additions & 2 deletions inst/biblioshiny/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ server <- function(input, output, session) {
need(values$nexus$check != FALSE, "\n\nNo topics in one or more periods. Please select a different set of parameters.")
)

isolate(plotThematicEvolution(values$nexus$Nodes,values$nexus$Edges))
isolate(plotThematicEvolution(values$nexus$Nodes,values$nexus$Edges, input$TEmeasure))
}


Expand All @@ -859,7 +859,7 @@ server <- function(input, output, session) {

TEData=values$nexus$Data
TEData=TEData[TEData$Inc_index>0,]
names(TEData)=c("From", "To", "Inclusion Index", "Words", "Occurrences", "Total", "Weighted Inclusion Index")
names(TEData)=c("From", "To", "Inclusion Index", "Words", "Occurrences", "Total", "Weighted Inclusion Index", "Total Occ From", "Total Occ To", "Stability Index")
DT::datatable(TEData, escape = FALSE, rownames = FALSE, extensions = c("Buttons"),filter = 'top',
options = list(pageLength = 50, dom = 'Bfrtip',
buttons = c('pageLength','copy','excel', 'pdf', 'print'),
Expand Down
6 changes: 6 additions & 0 deletions inst/biblioshiny/ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,12 @@ navbarMenu("Conceptual Structure",
selected = "ID"),
sliderInput("nTE", label="Number of Words",value=250,min=50,max=500,step=10),
sliderInput("fTE", label="Min Cluster Frequency",value=5,min=1,max=100,step=1),
selectInput("TEmeasure",
label = "Weight index",
choices = c("Inclusion Index" = "inclusion",
"Stability Index" = "stability"
),
selected = "inclusion"),
numericInput("numSlices", label="Number of Cutting Points",min=1,max=4,value=1),
"Please, write the cutting points (in year) for your collection",
uiOutput("sliders"),
Expand Down
4 changes: 3 additions & 1 deletion man/plotThematicEvolution.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 60b47ef

Please sign in to comment.