From 65417be388755db98f81e641d6835c706f28342d Mon Sep 17 00:00:00 2001 From: Massimo Aria Date: Tue, 8 Jan 2019 18:59:16 +0100 Subject: [PATCH] bibliometrix v2.1.0 ============== New functionality: * biblioshiny networks are now plotted using VisNetwork package. * biblioshiny menu have been completely rewritten. Now, descriptive analyses are organized by the unit of analysis * Several descriptive plots and tables have been added * Added the new funtion authorProdOverTime to calclulate and plot the productivity over the time of the top authors * Added "measure" parameter in plotThematicEvolution * Added the new function bib2df. It give the possibility to import data from a "generic" bibtex file format (i.e. Zotero, JabRef, etc.) * Added the possibility to calculate H-index for sources --- DESCRIPTION | 4 +- NAMESPACE | 1 + NEWS | 7 +- R/Hindex.R | 4 +- R/authorProdOverTime.R | 76 ++ R/biblioshiny.R | 1 + R/networkPlot.R | 10 +- R/summary.bibliometrix.R | 18 +- inst/biblioshiny/server.R | 1481 ++++++++++++++++++++++++------------- inst/biblioshiny/ui.R | 815 ++++++++++++++------ man/authorProdOverTime.Rd | 36 + 11 files changed, 1707 insertions(+), 746 deletions(-) create mode 100644 R/authorProdOverTime.R create mode 100644 man/authorProdOverTime.Rd diff --git a/DESCRIPTION b/DESCRIPTION index 83dbaa4c..1fe9645d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: bibliometrix Type: Package Title: An R-Tool for Comprehensive Science Mapping Analysis -Version: 2.0.3 -Date: 2018-11-19 +Version: 2.1.0 +Date: 2019-01-06 Authors@R: c(person("Massimo", "Aria", email = "aria@unina.it", role=c("cre","aut")), person("Corrado", "Cuccurullo", email = "cuccurullocorrado@gmail.com", role="aut")) Description: Tool for quantitative research in scientometrics and bibliometrics. diff --git a/NAMESPACE b/NAMESPACE index 6aadef91..84e06382 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -5,6 +5,7 @@ S3method(summary,bibliometrix) S3method(summary,bibliometrix_netstat) export(Hindex) export(KeywordGrowth) +export(authorProdOverTime) export(bib2df) export(biblioAnalysis) export(biblioNetwork) diff --git a/NEWS b/NEWS index dd593e0b..9d66dd4d 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,11 @@ -bibliometrix v2.0.3 (Release date: 2018-11-19) +bibliometrix v2.1.0 (Release date: 2019-01-06) ============== New functionality: +* biblioshiny networks are now plotted using VisNetwork package. +* biblioshiny menu have been completely rewritten. Now, descriptive analyses are organized by the unit of analysis +* Several descriptive plots and tables have been added +* Added the new funtion authorProdOverTime to calclulate and plot the productivity over the time of the top authors * Added "measure" parameter in plotThematicEvolution * Added the new function bib2df. It give the possibility to import data from a "generic" bibtex file format (i.e. Zotero, JabRef, etc.) * Added the possibility to calculate H-index for sources @@ -10,6 +14,7 @@ New functionality: Changes: * Completely rewritten the importing function from bibtex files * Solved an issue in dominance(). Now Dominance factor in correctly calculated +* Solved sevaral issues in importing functions due to inconsistence in WOS/SCOPUS web-exporting procedures diff --git a/R/Hindex.R b/R/Hindex.R index 3f24ca4c..037b778b 100644 --- a/R/Hindex.R +++ b/R/Hindex.R @@ -70,7 +70,7 @@ Hindex <- function(M, field="author", elements, sep = ";",years=10){ ## identify manuscripts of the author or of the sources - H=data.frame(Element=elements,h_index=0,g_index=0,m_index=0,TC=0,NP=0) + H=data.frame(Element=elements,h_index=0,g_index=0,m_index=0,TC=0,NP=0, stringsAsFactors = FALSE) TotalCitations=list() for (j in 1:length(elements)){ author=elements[j] @@ -92,7 +92,7 @@ Hindex <- function(M, field="author", elements, sep = ";",years=10){ } #TotalCitations[[j]]=data.frame(Year=as.numeric(M$PY[ind]),TC,Year2=sort(as.numeric(M$PY[ind])),TC2) if (length(ind)>0){ - df=data.frame(Authors=substr(M$AU[ind], 1, 30),Journal=substr(M$SO[ind], 1, 30),Year=as.numeric(M$PY[ind]),TotalCitation=M$TC[ind]) + df=data.frame(Authors=substr(M$AU[ind], 1, 30),Journal=substr(M$SO[ind], 1, 30),Year=as.numeric(M$PY[ind]),TotalCitation=M$TC[ind], stringsAsFactors = FALSE) TotalCitations[[j]]=df[order(df$TotalCitation),] } } diff --git a/R/authorProdOverTime.R b/R/authorProdOverTime.R new file mode 100644 index 00000000..11ce406b --- /dev/null +++ b/R/authorProdOverTime.R @@ -0,0 +1,76 @@ +#' Top-Authors' Productivity over the Time +#' +#' It calculates and plots the author production (in terms of number of publications) over the time. +#' @param M is a bibliographic data frame obtained by \code{\link{convert2df}} function. +#' @param k is a integer. It is the number of top auhtors to analize and plot. Default is \code{k = 10}. +#' @param graph is logical. If TRUE the function plots the author production over time graph. Default is \code{graph = TRE}. +#' @return The function \code{authorProdOverTime} returns a list containing two objects: +#' \tabular{lll}{ +#' \code{dfAU} \tab \tab is a data frame\cr +#' \code{graph} \tab \tab a ggplot object} +#' +#' @examples +#' data(scientometrics) +#' res <- authorProdOverTime(scientometrics, k=10) +#' print(res$dfAU) +#' plot(res$graph) +#' +#' @seealso \code{\link{biblioAnalysis}} function for bibliometric analysis +#' @seealso \code{\link{summary}} method for class '\code{bibliometrix}' +#' +#' @export +#' +authorProdOverTime <- function(M,k=10, graph=TRUE){ + + M$TC=as.numeric(M$TC) + M$PY=as.numeric(M$PY) + AU=names(tableTag(M,"AU")) + k=min(k,length(AU)) + AU=AU[1:k] + #AU=names(AU) + df=data.frame("Author"="NA","year"=NA, "TC"=NA,"TCpY"=NA,stringsAsFactors = FALSE) + Y=as.numeric(substr(Sys.time(),1,4)) + for (i in 1:length(AU)){ + + ind=which(regexpr(AU[i],M$AU)>-1) + TCpY=M$TC[ind]/(Y-M$PY[ind]+1) + dfAU=data.frame("Author"=rep(AU[i],length(ind)),"year"=M$PY[ind],"TC"=M$TC[ind], "TCpY"=TCpY,stringsAsFactors = TRUE) + df=rbind(df,dfAU) + } + df=df[-1,] + + df2<-dplyr::group_by(df, Author,year) %>% + dplyr::summarise(freq=length(year),TC=sum(TC),TCpY=sum(TCpY)) + + df2=as.data.frame(df2) + df2$Author=factor(df2$Author,levels=AU[1:k]) + #theme_set(theme_bw()) + + g <- ggplot(df2, aes(Author, year))+ + geom_point(aes(alpha=df2$TCpY,size = df2$freq), color="dodgerblue4")+ + scale_size(range=c(2,6))+ + scale_alpha(range=c(0.3,1))+ + scale_y_continuous(breaks = seq(min(df2$year),max(df2$year), by=2))+ + guides(size = guide_legend(order = 1, "N.Articles"), alpha = guide_legend(order = 2, "TC per Year"))+ + theme(text = element_text(color = "#444444") + ,panel.background = element_rect(fill = 'gray97') + ,panel.grid.minor = element_line(color = '#FFFFFF') + ,panel.grid.major = element_line(color = '#FFFFFF') + ,plot.title = element_text(size = 24) + ,axis.title = element_text(size = 14, color = '#555555') + ,axis.title.y = element_text(vjust = 1, angle = 0, face="bold") + ,axis.title.x = element_text(hjust = .95, face="bold") + ,axis.text.x = element_text(face="bold") + ,axis.text.y = element_text(face="bold") + )+ + labs(title="Top-Authors' Productivity over the Time", + x="Author", + y="Year")+ + geom_line(data=df2, aes(x = df2$Author, y = df2$year),size=1.0, color="firebrick", alpha=0.3 )+ + scale_x_discrete(limits = rev(levels(df2$Author)))+ + coord_flip() + res <- list(dfAU=df2,graph=g) + if (isTRUE(graph)){plot(g)} + return(res) +} + diff --git a/R/biblioshiny.R b/R/biblioshiny.R index 1b89732a..aca219b5 100644 --- a/R/biblioshiny.R +++ b/R/biblioshiny.R @@ -10,5 +10,6 @@ #' @export biblioshiny <- function(){ + runApp(system.file("biblioshiny",package="bibliometrix"),launch.browser = TRUE) } \ No newline at end of file diff --git a/R/networkPlot.R b/R/networkPlot.R index 5d9a5baf..8699b87c 100644 --- a/R/networkPlot.R +++ b/R/networkPlot.R @@ -90,7 +90,7 @@ networkPlot<-function(NetMatrix, normalize=NULL, n=NULL, degree=NULL, Title="Plo # vertex labels - V(bsk.network)$name <- colnames(NET) + V(bsk.network)$name <- tolower(colnames(NET)) # Compute node degrees (#links) and use that to set node size: @@ -164,6 +164,8 @@ networkPlot<-function(NetMatrix, normalize=NULL, n=NULL, degree=NULL, Title="Plo if (q<0){q=0} q=quantile(V(bsk.network)$deg,q) LABEL[V(bsk.network)$deg to see next table: ") line <- readline()} - + if (K==Inf){ + k=length(object$Countries) + } kk=k if (!is.null(object$Countries)){ # Most Productive Countries @@ -190,6 +198,9 @@ summary.bibliometrix<-function(object, ...){ if (!is.null(object$Sources)){ # Most relevant Sources if (isTRUE(verbose)){cat("\nMost Relevant Sources\n\n")} + if (K==Inf){ + k=length(object$Sources) + } kk=k if (length(object$Sources)% + formatStyle(names(TAB), backgroundColor = 'white',textAlign = 'center', fontSize = '110%') + }) + + output$AnnualProdPlot <- renderPlot({ + res <- descriptive(values,type="tab2") + values <-res$values + Tab=table(values$results$Years) + ## inserting missing years + YY=setdiff(seq(min(values$results$Years),max(values$results$Years)),names(Tab)) + Y=data.frame(Year=as.numeric(c(names(Tab),YY)),Freq=c(as.numeric(Tab),rep(0,length(YY)))) + Y=Y[order(Y$Year),] - switch(input$summary_type, - "tab1"={ - #TAB=data.frame(Information=gsub("[[:digit:]]", "", S$MainInformation), Data=gsub("[^0-9]", "", S$MainInformation)) - TAB=data.frame(S$MainInformationDF) - #cat(S$MainInformation) - }, - "tab2"={ - - TAB=S$AnnualProduction - names(TAB)=c("Year","Articles") - #print(S$AnnualProduction) - #cat("\n\n") - #cat("Annual Growth Rate ",round(S$AnnualGrowthRate, digits=2),"%") - }, - "tab3"={ - TAB=S$MostProdAuthors - names(TAB)=c("Authors","Articles","Authors-Frac","Articles Fractionalized") - #print(S$MostProdAuthors) - }, - "tab4"={ - TAB=S$MostCitedPapers - names(TAB)=c("Paper", "Total Citations","TC per Year") - #print(S$MostCitedPapers) - }, - "tab5"={ - TAB=S$MostProdCountries - #print(S$MostProdCountries) - }, - "tab6"={ - TAB=S$TCperCountries - #print(S$TCperCountries) - }, - "tab7"={ - TAB=S$MostRelSources - #print(S$MostRelSources) - }, - "tab8"={ - TAB=S$MostRelKeywords - names(TAB)=c("Author Keywords (DE)", "Articles (DE)","Keywords-Plus (ID)","Articles (ID)") - #print(S$MostRelKeywords) - }, - "tab9"={ - TAB=as.data.frame(citations(values$M,sep=";")$Cited) - names(TAB)=c("Cited References", "Citations") - #print(S$MostRelKeywords) - }, - "tab10"={ - TAB<-mapworld(values$M)$tab - } - ) + names(Y)=c("Year","Freq") + + g=ggplot2::ggplot(Y, aes(x = Y$Year, y = Y$Freq)) + + geom_line() + + geom_area(fill = '#002F80', alpha = .5) + + labs(x = 'Year' + , y = 'Articles' + , title = "Annual Scientific Production") + + scale_x_continuous(breaks= (Y$Year[seq(1,length(Y$Year),by=2)])) + + theme(text = element_text(color = "#444444") + ,panel.background = element_rect(fill = '#EFEFEF') + ,panel.grid.minor = element_line(color = '#FFFFFF') + ,panel.grid.major = element_line(color = '#FFFFFF') + ,plot.title = element_text(size = 24) + ,axis.title = element_text(size = 14, color = '#555555') + ,axis.title.y = element_text(vjust = 1, angle = 0) + ,axis.title.x = element_text(hjust = 0) + ) + plot(g) + }, height = 500, width =900) + + output$AnnualProdTable <- DT::renderDT({ + TAB <- values$TAB + DT::datatable(TAB, rownames = FALSE, extensions = c("Buttons"), + options = list(pageLength = 20, dom = 'Bfrtip', + buttons = c('pageLength','copy', 'csv', 'excel', 'pdf', 'print'), + lengthMenu = list(c(10,25,50,-1),c('10 rows', '25 rows', '50 rows','Show all')), + columnDefs = list(list(className = 'dt-center', targets = 0:(length(names(TAB))-1)))), + class = 'cell-border compact stripe') %>% + formatStyle(names(TAB), backgroundColor = 'white',textAlign = 'center', fontSize = '110%') + + }) + + ### SOURCES MENU #### + + output$MostRelSourcesTable <- DT::renderDT({ + + TAB <- values$TAB + DT::datatable(TAB, rownames = FALSE, extensions = c("Buttons"), + options = list(pageLength = 20, dom = 'Bfrtip', + buttons = c('pageLength','copy', 'csv', 'excel', 'pdf', 'print'), + lengthMenu = list(c(10,25,50,-1),c('10 rows', '25 rows', '50 rows','Show all')), + columnDefs = list(list(className = 'dt-center', targets = 0:(length(names(TAB))-1)))), + class = 'cell-border compact stripe') %>% + formatStyle(names(TAB), backgroundColor = 'white',textAlign = 'center', fontSize = '110%') + + }) + + output$MostRelSourcesPlot <- renderPlot({ + res <- descriptive(values,type="tab7") + values <-res$values + + xx=as.data.frame(values$results$Sources) + if (input$MostRelSourcesK>dim(xx)[1]){ + k=dim(xx)[1] + } else {k=input$MostRelSourcesK} + xx=xx[1:k,] + g=ggplot2::ggplot(data=xx, aes(x=xx$SO, y=xx$Freq, fill=-xx$Freq)) + + geom_bar(stat="identity")+ + scale_fill_continuous(type = "gradient")+ + scale_x_discrete(limits = rev(levels(xx$SO)))+ + labs(title="Most Relevant Sources", x = "Sources")+ + labs(y = "N. of Documents")+ + theme_minimal() + + guides(fill=FALSE)+ + coord_flip() + + plot(g) + }, height = 500, width =900) + + output$bradfordPlot <- renderPlot({ + + values$bradford=bradford(values$M) + values$bradford$graph + + },height = 600) + + output$bradfordTable <- DT::renderDT({ + + DT::datatable(values$bradford$table, rownames = FALSE, + options = list(pageLength = 20, dom = 'Bfrtip', + buttons = c('pageLength','copy','excel', 'pdf', 'print'), + lengthMenu = list(c(10,25,50,-1),c('10 rows', '25 rows', '50 rows','Show all')), + columnDefs = list(list(className = 'dt-center', targets = 0:(length(names(values$bradford$table))-1)))), + class = 'cell-border compact stripe') %>% + formatStyle(names(values$bradford$table), backgroundColor = 'white',textAlign = 'center') + }) + + output$SourceHindexPlot <- renderPlot({ + + input$applyHsource + + isolate(res <- Hindex_plot(values,type="source")) + + isolate(plot(res$g)) + + }, height = 500, width =900) + + output$SourceHindexTable <- DT::renderDT({ + + DT::datatable(values$H, rownames = FALSE, extensions = c("Buttons"), + options = list(pageLength = 20, dom = 'Bfrtip', + buttons = c('pageLength','copy', 'csv', 'excel', 'pdf', 'print'), + lengthMenu = list(c(10,25,50,-1),c('10 rows', '25 rows', '50 rows','Show all')), + columnDefs = list(list(className = 'dt-center', targets = 0:(length(names(values$H))-1)))), + class = 'cell-border compact stripe') %>% + formatStyle(names(values$H), backgroundColor = 'white',textAlign = 'center') + + }) + + output$soGrowthPlot <- renderPlot({ + + if (input$SOse=="Yes"){se=TRUE}else{se=FALSE} + + if (input$cumSO=="Cum"){ + cdf=TRUE + laby="Cumulate occurrences (loess smoothing)" + }else{ + cdf=FALSE + laby="Annual occurrences (loess smoothing)"} + + values$PYSO=sourceGrowth(values$M,input$topSO, cdf=cdf) + + term=names(values$PYSO)[-1] + term=rep(term,each=dim(values$PYSO)[1]) + n=dim(values$PYSO)[1]*(dim(values$PYSO)[2]-1) + freq=matrix(as.matrix(values$PYSO[,-1]),n,1) + values$SODF=data.frame(Year=rep(values$PYSO$Year,(dim(values$PYSO)[2]-1)),Source=term, Freq=freq) + + g=ggplot(values$SODF)+ + geom_smooth(aes(x=values$SODF$Year,y=values$SODF$Freq, group=values$SODF$Source, color=values$SODF$Source),se=se, method = "loess", formula="y ~ x")+ + labs(x = 'Year' + , y = laby + , title = "Source Growth") + + #ylim(0, NA) + + scale_x_continuous(breaks= (values$PYSO$Year[seq(1,length(values$PYSO$Year),by=ceiling(length(values$PYSO$Year)/20))])) + + geom_hline(aes(yintercept=0, alpha=0.1))+ + theme(text = element_text(color = "#444444"), legend.position="none" + ,plot.caption = element_text(size = 9, hjust = 0.5, color = "black", face = "bold") + ,panel.background = element_rect(fill = '#EFEFEF') + ,panel.grid.minor = element_line(color = '#FFFFFF') + ,panel.grid.major = element_line(color = '#FFFFFF') + ,plot.title = element_text(size = 24) + ,axis.title = element_text(size = 14, color = '#555555') + ,axis.title.y = element_text(vjust = 1, angle = 90) + ,axis.title.x = element_text(hjust = 0.95, angle = 0) + ,axis.text.x = element_text(size=10) + ) + + DFsmooth=(ggplot_build(g)$data[[1]]) + DFsmooth$group=factor(DFsmooth$group, labels=levels(values$SODF$Source)) + + maximum=sort(unique(DFsmooth$x),decreasing=TRUE)[2] + DF2=subset(DFsmooth, x == maximum) + g=g+ + ggrepel::geom_text_repel(data = DF2, aes(label = DF2$group, colour = DF2$group, x =DF2$x, y = DF2$y), hjust = -.1) + suppressWarnings(plot(g)) + + + },height = 600, width = 900) + + output$soGrowthtable <- DT::renderDT({ + + soData=values$PYSO + + DT::datatable(soData, escape = FALSE, rownames = FALSE, extensions = c("Buttons"), + options = list(pageLength = 50, dom = 'Bfrtip', + buttons = c('pageLength','copy','excel', 'pdf', 'print'), + lengthMenu = list(c(10,25,50,-1),c('10 rows', '25 rows', '50 rows','Show all')), + columnDefs = list(list(className = 'dt-center', targets = 0:(length(names(soData))-1))))) %>% + formatStyle(names(soData), backgroundColor = 'white') + #return(Data) + + }) + + ### AUHTORS MENU #### + + ### Authors ---- + output$MostRelAuthorsPlot <- renderPlot({ + res <- descriptive(values,type="tab3") + values <-res$values + + xx=as.data.frame(values$results$Authors, stringsAsFactors = FALSE) + if (input$MostRelAuthorsK>dim(xx)[1]){ + k=dim(xx)[1] + } else {k=input$MostRelAuthorsK} + xx=xx[1:k,] + g=ggplot2::ggplot(data=xx, aes(x=xx$AU, y=xx$Freq, fill=-xx$Freq)) + + geom_bar(stat="identity")+ + scale_fill_continuous(type = "gradient")+ + scale_x_discrete(limits = rev(xx$AU))+ + labs(title="Most Relevant Authors", x = "Authors")+ + labs(y = "N. of Documents")+ + theme_minimal() + + guides(fill=FALSE)+ + coord_flip() + + plot(g) + }, height = 500, width =900) + + output$MostRelAuthorsTable <- DT::renderDT({ + + TAB <- values$TAB + DT::datatable(TAB, rownames = FALSE, extensions = c("Buttons"), + options = list(pageLength = 20, dom = 'Bfrtip', + buttons = c('pageLength','copy', 'csv', 'excel', 'pdf', 'print'), + lengthMenu = list(c(10,25,50,-1),c('10 rows', '25 rows', '50 rows','Show all')), + columnDefs = list(list(className = 'dt-center', targets = 0:(length(names(TAB))-1)))), + class = 'cell-border compact stripe') %>% + formatStyle(names(TAB), backgroundColor = 'white',textAlign = 'center', fontSize = '110%') + + }) + + output$AuthorHindexPlot <- renderPlot({ + + input$applyHauthor + + isolate(res <- Hindex_plot(values,type="author")) + + isolate(plot(res$g)) + + }, height = 500, width =900) + + output$AuthorHindexTable <- DT::renderDT({ + + DT::datatable(values$H, rownames = FALSE, extensions = c("Buttons"), + options = list(pageLength = 20, dom = 'Bfrtip', + buttons = c('pageLength','copy', 'csv', 'excel', 'pdf', 'print'), + lengthMenu = list(c(10,25,50,-1),c('10 rows', '25 rows', '50 rows','Show all')), + columnDefs = list(list(className = 'dt-center', targets = 0:(length(names(values$H))-1)))), + class = 'cell-border compact stripe') %>% + formatStyle(names(values$H), backgroundColor = 'white',textAlign = 'center') + + }) + + output$TopAuthorsProdPlot <- renderPlot({ + values$AUProdOverTime <- authorProdOverTime(M, k=input$TopAuthorsProdK) + + plot(values$AUProdOverTime$graph) + }, height = 550, width =1100) + + output$TopAuthorsProdTable <- DT::renderDT({ + TAB <- values$AUProdOverTime$dfAU + DT::datatable(TAB, rownames = FALSE, extensions = c("Buttons"), + options = list(pageLength = 20, dom = 'Bfrtip', + buttons = c('pageLength','copy', 'csv', 'excel', 'pdf', 'print'), + lengthMenu = list(c(10,25,50,-1),c('10 rows', '25 rows', '50 rows','Show all')), + columnDefs = list(list(className = 'dt-center', targets = 0:(length(names(TAB))-1)))), + class = 'cell-border compact stripe') %>% + formatStyle(names(TAB), backgroundColor = 'white',textAlign = 'center', fontSize = '110%') + + }) + + output$lotkaPlot <- renderPlot({ + + values$lotka=lotka(biblioAnalysis(values$M)) + AuProd=values$lotka$AuthorProd + AuProd$Theoretical=10^(log10(values$lotka$C)-2*log10(AuProd[,1])) + + g=ggplot2::ggplot(AuProd, aes(x = AuProd$N.Articles, y = AuProd$Freq*100)) + + geom_line() + + geom_area(fill = '#002F80', alpha = .5) + + labs(x = 'N. Articles' + , y = '% of total scientific production' + , title = "Author Scientific Productivity") + + #scale_x_continuous(breaks= (Y$Year[seq(1,length(Y$Year),by=2)])) + + theme(text = element_text(color = "#444444") + ,panel.background = element_rect(fill = '#EFEFEF') + ,panel.grid.minor = element_line(color = '#FFFFFF') + ,panel.grid.major = element_line(color = '#FFFFFF') + ,plot.title = element_text(size = 24) + ,axis.title = element_text(size = 14, color = '#555555') + ,axis.title.y = element_text(vjust = 1, angle = 90) + ,axis.title.x = element_text(hjust = 0) + ) + plot(g) + + },height = 600) + + output$lotkaTable <- DT::renderDT({ + + DT::datatable(values$lotka$AuthorProd, rownames = FALSE, + options = list(pageLength = 20, dom = 'Bfrtip', + buttons = c('pageLength','copy','excel', 'pdf', 'print'), + lengthMenu = list(c(10,25,50,-1),c('10 rows', '25 rows', '50 rows','Show all')), + columnDefs = list(list(className = 'dt-center', targets = 0:(length(names(values$lotka$AuthorProd))-1)))), + class = 'cell-border compact stripe') %>% + formatStyle(names(values$lotka$AuthorProd), backgroundColor = 'white',textAlign = 'center') + }) + + ### Affiliations ---- + + output$MostRelAffiliationsPlot <- renderPlot({ + res <- descriptive(values,type="tab11") + values <-res$values + + xx=as.data.frame(values$results$Affiliations, stringsAsFactors = FALSE) + if (input$MostRelAffiliationsK>dim(xx)[1]){ + k=dim(xx)[1] + } else {k=input$MostRelAffiliationsK} + xx=xx[1:k,] + g=ggplot2::ggplot(data=xx, aes(x=xx$AFF, y=xx$Freq, fill=-xx$Freq)) + + geom_bar(stat="identity")+ + scale_fill_continuous(type = "gradient")+ + scale_x_discrete(limits = rev(xx$AFF))+ + labs(title="Most Relevant Affiliations", x = "Affiliations")+ + labs(y = "N. of Documents")+ + theme_minimal() + + guides(fill=FALSE)+ + coord_flip() + + plot(g) + }, height = 500, width =900) + + output$MostRelAffiliationsTable <- DT::renderDT({ + + TAB <- values$TAB + DT::datatable(TAB, rownames = FALSE, extensions = c("Buttons"), + options = list(pageLength = 20, dom = 'Bfrtip', + buttons = c('pageLength','copy', 'csv', 'excel', 'pdf', 'print'), + lengthMenu = list(c(10,25,50,-1),c('10 rows', '25 rows', '50 rows','Show all')), + columnDefs = list(list(className = 'dt-center', targets = 0:(length(names(TAB))-1)))), + class = 'cell-border compact stripe') %>% + formatStyle(names(TAB), backgroundColor = 'white',textAlign = 'center', fontSize = '110%') + + }) + + ### Countries ---- + + output$countryProdPlot <- renderPlot({ + values$mapworld<-mapworld(values$M) + plot(values$mapworld$g) + }, height = 500, width =900) + + output$countryProdTable <- DT::renderDT({ + + TAB <- values$mapworld$tab + DT::datatable(TAB, rownames = FALSE, extensions = c("Buttons"), + options = list(pageLength = 20, dom = 'Bfrtip', + buttons = c('pageLength','copy', 'csv', 'excel', 'pdf', 'print'), + lengthMenu = list(c(10,25,50,-1),c('10 rows', '25 rows', '50 rows','Show all')), + columnDefs = list(list(className = 'dt-center', targets = 0:(length(names(TAB))-1)))), + class = 'cell-border compact stripe') %>% + formatStyle(names(TAB), backgroundColor = 'white',textAlign = 'center', fontSize = '110%') + + }) + + output$MostCitCountriesPlot <- renderPlot({ + res <- descriptive(values,type="tab6") + values <-res$values + + xx=values$TAB + xx[,2]=as.numeric(xx[,2]) + xx[,3]=as.numeric(xx[,3]) + if (input$MostCitCountriesK>dim(xx)[1]){ + k=dim(xx)[1] + } else {k=input$MostRelAffiliationsK} + if (input$CitCountriesMeasure=="TC"){ + xx=xx[1:k,c(1,2)] + laby="N. of Citations" + } else { + xx=xx[order(-xx[,3]),] + xx=xx[1:k,c(1,3)] + laby="N. of Citations per Year" + } + + g=ggplot2::ggplot(data=xx, aes(x=xx[,1], y=xx[,2], fill=-xx[,2])) + + geom_bar(stat="identity")+ + scale_fill_continuous(type = "gradient")+ + scale_x_discrete(limits = rev(xx[,1]))+ + labs(title="Most Cited Countries", x = "Countries")+ + labs(y = laby)+ + theme_minimal() + + guides(fill=FALSE)+ + coord_flip() + + plot(g) + }, height = 500, width =900) + + output$MostCitCountriesTable <- DT::renderDT({ + + TAB <- values$TAB + DT::datatable(TAB, rownames = FALSE, extensions = c("Buttons"), + options = list(pageLength = 20, dom = 'Bfrtip', + buttons = c('pageLength','copy', 'csv', 'excel', 'pdf', 'print'), + lengthMenu = list(c(10,25,50,-1),c('10 rows', '25 rows', '50 rows','Show all')), + columnDefs = list(list(className = 'dt-center', targets = 0:(length(names(TAB))-1)))), + class = 'cell-border compact stripe') %>% + formatStyle(names(TAB), backgroundColor = 'white',textAlign = 'center', fontSize = '110%') + + }) + + ### DOCUMENTS MENU #### + + ### Documents ---- + output$MostCitDocsPlot <- renderPlot({ + res <- descriptive(values,type="tab4") + values <-res$values + + if (input$CitDocsMeasure=="TC"){ + xx=data.frame(values$results$MostCitedPapers[1],values$results$MostCitedPapers[2], stringsAsFactors = FALSE,row.names=NULL) + lab="Total Citations"} else { + xx=data.frame(values$results$MostCitedPapers[1],values$results$MostCitedPapers[3], stringsAsFactors = FALSE,row.names=NULL) + lab="Total Citations per Year" + } + + if (input$MostCitDocsK>dim(xx)[1]){ + k=dim(xx)[1] + } else {k=input$MostCitDocsK} + xx=xx[1:k,] + + g=ggplot2::ggplot(data=xx, aes(x=xx[,1], y=xx[,2], fill=-xx[,2])) + + geom_bar(stat="identity")+ + scale_fill_continuous(type = "gradient")+ + scale_x_discrete(limits = rev(xx[,1]))+ + labs(title="Most Cited Documents", x = "Documents")+ + labs(y = lab)+ + theme_minimal() + + guides(fill=FALSE)+ + coord_flip() + + plot(g) + }, height = 500, width =900) + + output$MostCitDocsTable <- DT::renderDT({ + + TAB <- values$TAB DT::datatable(TAB, rownames = FALSE, extensions = c("Buttons"), options = list(pageLength = 20, dom = 'Bfrtip', buttons = c('pageLength','copy', 'csv', 'excel', 'pdf', 'print'), @@ -257,235 +656,174 @@ server <- function(input, output, session) { columnDefs = list(list(className = 'dt-center', targets = 0:(length(names(TAB))-1)))), class = 'cell-border compact stripe') %>% formatStyle(names(TAB), backgroundColor = 'white',textAlign = 'center', fontSize = '110%') + }) - # - - output$results.txt <- downloadHandler( + + output$MostLocCitDocsPlot <- renderPlot({ - filename = function() { - paste("results-", Sys.Date(), ".txt", sep="") - }, - content <- function(file) { - values$S_text=capture.output(summary(object=values$results,k=input$kk)) - write(values$S_text, file, sep="\n") - }, + TAB <-localCitations(values$M, sep = input$LocCitSep)$Paper + + xx=data.frame(Document=as.character(TAB[,1]), DOI=as.character(TAB[,2]), Year=TAB[,3], "Local Citations"=TAB[,4], "Global Citations"=TAB[,5],stringsAsFactors = FALSE) + + values$TAB=xx + + if (input$MostLocCitDocsK>dim(xx)[1]){ + k=dim(xx)[1] + } else {k=input$MostLocCitDocsK} + + xx=xx[1:k,] + + g=ggplot2::ggplot(data=xx, aes(x=xx[,1], y=xx[,4], fill=-xx[,4])) + + geom_bar(stat="identity")+ + scale_fill_continuous(type = "gradient")+ + scale_x_discrete(limits = rev(xx[,1]))+ + labs(title="Most Local Cited Documents", x = "Documents")+ + labs(y = "Local Citations")+ + theme_minimal() + + guides(fill=FALSE)+ + coord_flip() - contentType = "txt" - ) - output$summaryPlots <- renderPlot({ - if (values$results[[1]]=="NA"){ - values$results=biblioAnalysis(values$M)} - k=input$k - switch(input$plot_type, - authors={ - xx=as.data.frame(values$results$Authors[1:k]) - g=ggplot2::ggplot(data=xx, aes(x=xx$AU, y=xx$Freq)) + - geom_bar(stat="identity", fill="steelblue")+ - scale_x_discrete(limits = rev(levels(xx$AU)))+ - labs(title="Most productive Authors", x = "Authors")+ - labs(y = "N. of Documents")+ - theme_minimal() + - coord_flip() - - }, - countries={ - xx=values$results$CountryCollaboration[1:k,] - xx=xx[order(-(xx$SCP+xx$MCP)),] - xx1=cbind(xx[,1:2],rep("SCP",k)) - names(xx1)=c("Country","Freq","Collaboration") - xx2=cbind(xx[,c(1,3)],rep("MCP",k)) - names(xx2)=c("Country","Freq","Collaboration") - xx=rbind(xx2,xx1) - xx$Country=factor(xx$Country,levels=xx$Country[1:dim(xx2)[1]]) - g=suppressWarnings(ggplot2::ggplot(data=xx, aes(x=xx$Country, y=xx$Freq,fill=xx$Collaboration)) + - geom_bar(stat="identity")+ - scale_x_discrete(limits = rev(levels(xx$Country)))+ - scale_fill_discrete(name="Collaboration", - breaks=c("SCP","MCP"))+ - labs(title = "Corresponding Author's Country", x = "Countries", y = "N. of Documents", - caption = "SCP: Single Country Publications, MCP: Multiple Country Publications")+ - theme_minimal() + - theme(plot.caption = element_text(size = 9, hjust = 0.5, - color = "blue", face = "italic"))+ - coord_flip()) - }, - mapworld={ - g<-mapworld(values$M)$g - }, - production={ - Tab=table(values$results$Years) - - ## inserting missing years - YY=setdiff(seq(min(values$results$Years),max(values$results$Years)),names(Tab)) - Y=data.frame(Year=as.numeric(c(names(Tab),YY)),Freq=c(as.numeric(Tab),rep(0,length(YY)))) - Y=Y[order(Y$Year),] - - names(Y)=c("Year","Freq") - - g=ggplot2::ggplot(Y, aes(x = Y$Year, y = Y$Freq)) + - geom_line() + - geom_area(fill = '#002F80', alpha = .5) + - labs(x = 'Year' - , y = 'Articles' - , title = "Annual Scientific Production") + - scale_x_continuous(breaks= (Y$Year[seq(1,length(Y$Year),by=2)])) + - theme(text = element_text(color = "#444444") - ,panel.background = element_rect(fill = '#EFEFEF') - ,panel.grid.minor = element_line(color = '#FFFFFF') - ,panel.grid.major = element_line(color = '#FFFFFF') - ,plot.title = element_text(size = 24) - ,axis.title = element_text(size = 14, color = '#555555') - ,axis.title.y = element_text(vjust = 1, angle = 0) - ,axis.title.x = element_text(hjust = 0) - ) - }, - articleTC={ - Table2=aggregate(values$results$TotalCitation,by=list(values$results$Years),length) - Table2$xx=aggregate(values$results$TotalCitation,by=list(values$results$Years),mean)$x - Table2$Annual=NA - d=date() - d=as.numeric(substring(d,nchar(d)-3,nchar(d))) - Table2$Years=d-Table2$Group.1 - Table2$Annual=Table2$xx/Table2$Years - names(Table2)=c("Year","N","MeanTCperArt","MeanTCperYear","CitableYears") - - ## inserting missing years - YY=setdiff(seq(min(values$results$Years),max(values$results$Years)),Table2$Year) - if (length(YY>0)){ - YY=data.frame(YY,0,0,0,0) - names(YY)=c("Year","N","MeanTCperArt","MeanTCperYear","CitableYears") - Table2=rbind(Table2,YY) - Table2=Table2[order(Table2$Year),] - row.names(Table2)=Table2$Year} - - - g=ggplot2::ggplot(Table2, aes(x = Table2$Year, y = Table2$MeanTCperYear)) + - geom_line() + - geom_area(fill = '#002F80', alpha = .5) + - labs(x = 'Publication Year' - , y = 'Citations' - , title = "Average Article Citations per Year")+ - scale_x_continuous(breaks= (Table2$Year[seq(1,length(Table2$Year),by=2)])) + - theme(text = element_text(color = "#444444") - ,panel.background = element_rect(fill = '#EFEFEF') - ,panel.grid.minor = element_line(color = '#FFFFFF') - ,panel.grid.major = element_line(color = '#FFFFFF') - ,plot.title = element_text(size = 24) - ,axis.title = element_text(size = 14, color = '#555555') - ,axis.title.y = element_text(vjust = 1, angle = 0) - ,axis.title.x = element_text(hjust = 0) - ) - }, - annualTC={ - Table2=aggregate(values$results$TotalCitation,by=list(values$results$Years),length) - Table2$xx=aggregate(values$results$TotalCitation,by=list(values$results$Years),mean)$x - Table2$Annual=NA - d=date() - d=as.numeric(substring(d,nchar(d)-3,nchar(d))) - Table2$Years=d-Table2$Group.1 - Table2$Annual=Table2$xx/Table2$Years - names(Table2)=c("Year","N","MeanTCperArt","MeanTCperYear","CitableYears") - - ## inserting missing years - YY=setdiff(seq(min(values$results$Years),max(values$results$Years)),Table2$Year) - if (length(YY>0)){ - YY=data.frame(YY,0,0,0,0) - names(YY)=c("Year","N","MeanTCperArt","MeanTCperYear","CitableYears") - Table2=rbind(Table2,YY) - Table2=Table2[order(Table2$Year),] - row.names(Table2)=Table2$Year} - - g=ggplot2::ggplot(Table2, aes(x = Table2$Year, y = Table2$MeanTCperArt)) + - geom_line() + - geom_area(fill = '#002F80', alpha = .5) + - labs(x = 'Publication Year' - , y = 'Citations' - , title = "Average Total Citations per Year")+ - scale_x_continuous(breaks= (Table2$Year[seq(1,length(Table2$Year),by=2)])) + - theme(text = element_text(color = "#444444") - ,panel.background = element_rect(fill = '#EFEFEF') - ,panel.grid.minor = element_line(color = '#FFFFFF') - ,panel.grid.major = element_line(color = '#FFFFFF') - ,plot.title = element_text(size = 24) - ,axis.title = element_text(size = 14, color = '#555555') - ,axis.title.y = element_text(vjust = 1, angle = 0) - ,axis.title.x = element_text(hjust = 0, angle = 0) - ) - } - ) plot(g) - #plot(results) - }, height = 500, width =900) + }, height = 500, width =900) - output$hindexTable <- DT::renderDT({ - - input$applyH + output$MostLocCitDocsTable <- DT::renderDT({ - isolate(values<-hindex(input, values)) - - isolate(DT::datatable(values$H, rownames = FALSE, + TAB <- values$TAB + TAB$DOI<- paste0('',TAB$DOI,'') + DT::datatable(TAB, escape = FALSE, rownames = FALSE, extensions = c("Buttons"), options = list(pageLength = 20, dom = 'Bfrtip', - buttons = c('pageLength','copy','excel', 'pdf', 'print'), + buttons = c('pageLength','copy', 'csv', 'excel', 'pdf', 'print'), lengthMenu = list(c(10,25,50,-1),c('10 rows', '25 rows', '50 rows','Show all')), - columnDefs = list(list(className = 'dt-center', targets = 0:(length(names(values$H))-1)))), + columnDefs = list(list(className = 'dt-center', targets = 0:(length(names(TAB))-1)))), class = 'cell-border compact stripe') %>% - formatStyle(names(values$H), backgroundColor = 'white',textAlign = 'center')) - + formatStyle(names(TAB), backgroundColor = 'white',textAlign = 'center', fontSize = '110%') + }) - output$bradfordPlot <- renderPlot({ + ### Cited References ---- + + output$MostCitRefsPlot <- renderPlot({ + CR=citations(values$M,sep=input$CitRefsSep)$Cited + TAB=data.frame(names(CR),as.numeric(CR),stringsAsFactors = FALSE) + names(TAB)=c("Cited References", "Citations") + values$TAB=TAB - values$bradford=bradford(values$M) - values$bradford$graph + xx=values$TAB + if (input$MostCitRefsK>dim(xx)[1]){ + k=dim(xx)[1] + } else {k=input$MostCitRefsK} - },height = 600) + xx=xx[1:k,] + + g=ggplot2::ggplot(data=xx, aes(x=xx[,1], y=xx[,2], fill=-xx[,2])) + + geom_bar(stat="identity")+ + scale_fill_continuous(type = "gradient")+ + scale_x_discrete(limits = rev(xx[,1]))+ + labs(title="Most Cited References", x = "Documents")+ + labs(y = "Local Citations")+ + theme_minimal() + + guides(fill=FALSE)+ + coord_flip() + + plot(g) + }, height = 500, width =900) - output$bradfordTable <- DT::renderDT({ + output$MostCitRefsTable <- DT::renderDT({ - DT::datatable(values$bradford$table, rownames = FALSE, + TAB <- values$TAB + DT::datatable(TAB, rownames = FALSE, extensions = c("Buttons"), options = list(pageLength = 20, dom = 'Bfrtip', - buttons = c('pageLength','copy','excel', 'pdf', 'print'), + buttons = c('pageLength','copy', 'csv', 'excel', 'pdf', 'print'), lengthMenu = list(c(10,25,50,-1),c('10 rows', '25 rows', '50 rows','Show all')), - columnDefs = list(list(className = 'dt-center', targets = 0:(length(names(values$bradford$table))-1)))), + columnDefs = list(list(className = 'dt-center', targets = 0:(length(names(TAB))-1)))), class = 'cell-border compact stripe') %>% - formatStyle(names(values$bradford$table), backgroundColor = 'white',textAlign = 'center') + formatStyle(names(TAB), backgroundColor = 'white',textAlign = 'center', fontSize = '110%') + }) - output$lotkaPlot <- renderPlot({ + output$rpysPlot <- renderPlot({ + values$res <- rpys(values$M, sep=input$rpysSep, timespan=input$sliderYears ,graph=FALSE) + #values$res <- rpys(values$M, sep=input$rpysSep, timespan=input$sliderYears ,graph=FALSE) + plot(values$res$spectroscopy) - values$lotka=lotka(biblioAnalysis(values$M)) - AuProd=values$lotka$AuthorProd - AuProd$Theoretical=10^(log10(values$lotka$C)-2*log10(AuProd[,1])) - - g=ggplot2::ggplot(AuProd, aes(x = AuProd$N.Articles, y = AuProd$Freq*100)) + - geom_line() + - geom_area(fill = '#002F80', alpha = .5) + - labs(x = 'N. Articles' - , y = '% of total scientific production' - , title = "Author Scientific Productivity") + - #scale_x_continuous(breaks= (Y$Year[seq(1,length(Y$Year),by=2)])) + - theme(text = element_text(color = "#444444") - ,panel.background = element_rect(fill = '#EFEFEF') - ,panel.grid.minor = element_line(color = '#FFFFFF') - ,panel.grid.major = element_line(color = '#FFFFFF') - ,plot.title = element_text(size = 24) - ,axis.title = element_text(size = 14, color = '#555555') - ,axis.title.y = element_text(vjust = 1, angle = 90) - ,axis.title.x = element_text(hjust = 0) - ) - plot(g) - - },height = 600) + },height = 600, width = 900) - output$lotkaTable <- DT::renderDT({ + output$rpysTable <- DT::renderDT({ - DT::datatable(values$lotka$AuthorProd, rownames = FALSE, - options = list(pageLength = 20, dom = 'Bfrtip', + rpysData=values$res$rpysTable + + DT::datatable(rpysData, escape = FALSE, rownames = FALSE, extensions = c("Buttons"), + options = list(pageLength = 50, dom = 'Bfrtip', buttons = c('pageLength','copy','excel', 'pdf', 'print'), lengthMenu = list(c(10,25,50,-1),c('10 rows', '25 rows', '50 rows','Show all')), - columnDefs = list(list(className = 'dt-center', targets = 0:(length(names(values$lotka$AuthorProd))-1)))), + columnDefs = list(list(className = 'dt-center', targets = 0:(length(names(rpysData))-1))))) %>% + formatStyle(names(rpysData), backgroundColor = 'white') + #return(Data) + + }) + + output$crTable <- DT::renderDT({ + + crData=values$res$CR + crData=crData[order(-as.numeric(crData$Year),-crData$Freq),] + names(crData)=c("Year", "Reference", "Local Citations") + DT::datatable(crData, escape = FALSE, rownames = FALSE, extensions = c("Buttons"),filter = 'top', + options = list(pageLength = 50, dom = 'Bfrtip', + buttons = c('pageLength','copy','excel', 'pdf', 'print'), + lengthMenu = list(c(10,25,50,-1),c('10 rows', '25 rows', '50 rows','Show all')), + columnDefs = list(list(className = 'dt-center', targets = 0:(length(names(crData))-1))))) %>% + formatStyle(names(crData), backgroundColor = 'white') + #return(Data) + + }) + + ### Words ---- + + output$MostRelWordsPlot <- renderPlot({ + WR=wordlist(values$M,Field=input$MostRelWords,n=Inf,measure="identity")$v + + TAB=data.frame(names(WR),as.numeric(WR),stringsAsFactors = FALSE) + names(TAB)=c("Words", "Occurrences") + values$TAB=TAB + + xx=values$TAB + if (input$MostRelWordsN>dim(xx)[1]){ + k=dim(xx)[1] + } else {k=input$MostRelWordsN} + + xx=xx[1:k,] + switch(input$MostRelWords, + ID={lab="Keywords Plus"}, + DE={lab="Auhtor's Keywords"}, + TI={lab="Title's Words"}, + AB={lab="Abstract's Words"}) + + g=ggplot2::ggplot(data=xx, aes(x=xx[,1], y=xx[,2], fill=-xx[,2])) + + geom_bar(stat="identity")+ + scale_fill_continuous(type = "gradient")+ + scale_x_discrete(limits = rev(xx[,1]))+ + labs(title="Most Relevant Words", x = lab)+ + labs(y = "Occurrences")+ + theme_minimal() + + guides(fill=FALSE)+ + coord_flip() + + plot(g) + }, height = 500, width =900) + + output$MostRelWordsTable <- DT::renderDT({ + + + TAB <- values$TAB + + DT::datatable(TAB, rownames = FALSE, extensions = c("Buttons"), + options = list(pageLength = 20, dom = 'Bfrtip', + buttons = c('pageLength','copy', 'csv', 'excel', 'pdf', 'print'), + lengthMenu = list(c(10,25,50,-1),c('10 rows', '25 rows', '50 rows','Show all')), + columnDefs = list(list(className = 'dt-center', targets = 0:(length(names(TAB))-1)))), class = 'cell-border compact stripe') %>% - formatStyle(names(values$lotka$AuthorProd), backgroundColor = 'white',textAlign = 'center') + formatStyle(names(TAB), backgroundColor = 'white',textAlign = 'center', fontSize = '110%') + }) output$wordcloud <- wordcloud2::renderWordcloud2({ @@ -631,123 +969,28 @@ server <- function(input, output, session) { }) - output$soGrowthPlot <- renderPlot({ - - if (input$SOse=="Yes"){se=TRUE}else{se=FALSE} - - if (input$cumSO=="Cum"){ - cdf=TRUE - laby="Cumulate occurrences (loess smoothing)" - }else{ - cdf=FALSE - laby="Annual occurrences (loess smoothing)"} - - values$PYSO=sourceGrowth(values$M,input$topSO, cdf=cdf) - - term=names(values$PYSO)[-1] - term=rep(term,each=dim(values$PYSO)[1]) - n=dim(values$PYSO)[1]*(dim(values$PYSO)[2]-1) - freq=matrix(as.matrix(values$PYSO[,-1]),n,1) - values$SODF=data.frame(Year=rep(values$PYSO$Year,(dim(values$PYSO)[2]-1)),Source=term, Freq=freq) - - g=ggplot(values$SODF)+ - geom_smooth(aes(x=values$SODF$Year,y=values$SODF$Freq, group=values$SODF$Source, color=values$SODF$Source),se=se, method = "loess", formula="y ~ x")+ - labs(x = 'Year' - , y = laby - , title = "Source Growth") + - #ylim(0, NA) + - scale_x_continuous(breaks= (values$PYSO$Year[seq(1,length(values$PYSO$Year),by=ceiling(length(values$PYSO$Year)/20))])) + - geom_hline(aes(yintercept=0, alpha=0.1))+ - theme(text = element_text(color = "#444444"), legend.position="none" - ,plot.caption = element_text(size = 9, hjust = 0.5, color = "black", face = "bold") - ,panel.background = element_rect(fill = '#EFEFEF') - ,panel.grid.minor = element_line(color = '#FFFFFF') - ,panel.grid.major = element_line(color = '#FFFFFF') - ,plot.title = element_text(size = 24) - ,axis.title = element_text(size = 14, color = '#555555') - ,axis.title.y = element_text(vjust = 1, angle = 90) - ,axis.title.x = element_text(hjust = 0.95, angle = 0) - ,axis.text.x = element_text(size=10) - ) - - DFsmooth=(ggplot_build(g)$data[[1]]) - DFsmooth$group=factor(DFsmooth$group, labels=levels(values$SODF$Source)) - - maximum=sort(unique(DFsmooth$x),decreasing=TRUE)[2] - DF2=subset(DFsmooth, x == maximum) - g=g+ - ggrepel::geom_text_repel(data = DF2, aes(label = DF2$group, colour = DF2$group, x =DF2$x, y = DF2$y), hjust = -.1) - suppressWarnings(plot(g)) - - - # maximum=sort(unique(values$SODF$Year),decreasing=TRUE)[2] - # DF2=subset(values$SODF, Year == maximum) - # g=g+ - # ggrepel::geom_text_repel(data = DF2, aes(label = DF2$Source, colour = DF2$Source, x =DF2$Year, y = DF2$Freq), hjust = -.1) - # - # plot(g) - - },height = 600, width = 900) + - output$soGrowthtable <- DT::renderDT({ - - soData=values$PYSO - - DT::datatable(soData, escape = FALSE, rownames = FALSE, extensions = c("Buttons"), - options = list(pageLength = 50, dom = 'Bfrtip', - buttons = c('pageLength','copy','excel', 'pdf', 'print'), - lengthMenu = list(c(10,25,50,-1),c('10 rows', '25 rows', '50 rows','Show all')), - columnDefs = list(list(className = 'dt-center', targets = 0:(length(names(soData))-1))))) %>% - formatStyle(names(soData), backgroundColor = 'white') - #return(Data) - - }) + ### Conceptual Structure ##### + + ### Co-occurrences network ---- + output$cocPlot <- renderVisNetwork({ - output$rpysPlot <- renderPlot({ - values$res <- rpys(values$M, sep=input$rpysSep, timespan=input$sliderYears ,graph=FALSE) - #values$res <- rpys(values$M, sep=input$rpysSep, timespan=input$sliderYears ,graph=FALSE) - plot(values$res$spectroscopy) + input$applyCoc - },height = 600, width = 900) - - output$rpysTable <- DT::renderDT({ + t = tempfile();pdf(file=t) #### trick to hide igraph plot + values <- isolate(cocNetwork(input,values)) + dev.off();file.remove(t) ### end of trick - rpysData=values$res$rpysTable + isolate(values$network<-igraph2vis(g=values$cocnet$graph,curved=(input$coc.curved=="Yes"), + labelsize=input$labelsize, opacity=input$cocAlpha,type=input$layout)) - DT::datatable(rpysData, escape = FALSE, rownames = FALSE, extensions = c("Buttons"), - options = list(pageLength = 50, dom = 'Bfrtip', - buttons = c('pageLength','copy','excel', 'pdf', 'print'), - lengthMenu = list(c(10,25,50,-1),c('10 rows', '25 rows', '50 rows','Show all')), - columnDefs = list(list(className = 'dt-center', targets = 0:(length(names(rpysData))-1))))) %>% - formatStyle(names(rpysData), backgroundColor = 'white') - #return(Data) + isolate(values$network$VIS) }) - output$crTable <- DT::renderDT({ - - crData=values$res$CR - crData=crData[order(-as.numeric(crData$Year),-crData$Freq),] - names(crData)=c("Year", "Reference", "Local Citations") - DT::datatable(crData, escape = FALSE, rownames = FALSE, extensions = c("Buttons"),filter = 'top', - options = list(pageLength = 50, dom = 'Bfrtip', - buttons = c('pageLength','copy','excel', 'pdf', 'print'), - lengthMenu = list(c(10,25,50,-1),c('10 rows', '25 rows', '50 rows','Show all')), - columnDefs = list(list(className = 'dt-center', targets = 0:(length(names(crData))-1))))) %>% - formatStyle(names(crData), backgroundColor = 'white') - #return(Data) - - }) - ### Conceptual Structure - output$cocPlot <- renderPlot({ - - ## Keyword co-occurrences network - input$applyCoc - - values <- isolate(cocNetwork(input,values)) - - }, height = 750, width = 900) + output$network.coc <- downloadHandler( filename = "Co_occurrence_network.net", @@ -757,6 +1000,15 @@ server <- function(input, output, session) { }, contentType = "net" ) + + ### save coc network image as html #### + output$networkCoc.fig <- downloadHandler( + filename = "network.html", + content <- function(con) { + savenetwork(con) + }, + contentType = "html" + ) output$cocTable <- DT::renderDT({ @@ -772,6 +1024,7 @@ server <- function(input, output, session) { }) + ### Correspondence Analysis ---- output$CSPlot1 <- renderPlot({ input$applyCA @@ -811,6 +1064,7 @@ server <- function(input, output, session) { }, height = 650, width = 800) + ### Temathic Map ---- output$TMPlot <- renderPlot({ input$applyTM @@ -841,6 +1095,7 @@ server <- function(input, output, session) { }) + ### Temathic Evolution ---- output$sliders <- renderUI({ numSlices <- as.integer(input$numSlices) lapply(1:numSlices, function(i) { @@ -887,17 +1142,23 @@ server <- function(input, output, session) { }) - output$cocitPlot <- renderPlot({ - - ## Co-citation network + ### INTELLECTUAL STRUCTURE #### + + ### Co-citation network ---- + output$cocitPlot <- renderVisNetwork({ input$applyCocit + t = tempfile();pdf(file=t) #### trick to hide igraph plot values <- isolate(intellectualStructure(input,values)) + dev.off();file.remove(t) ### end of trick + isolate(values$network<-igraph2vis(g=values$cocitnet$graph,curved=(input$cocit.curved=="Yes"), + labelsize=input$citlabelsize, opacity=input$cocitAlpha,type=input$citlayout)) - - }, height = 750, width = 900) + isolate(values$network$VIS) + + }) output$network.cocit <- downloadHandler( filename = "Co_citation_network.net", @@ -922,6 +1183,15 @@ server <- function(input, output, session) { }) + ### save coc network image as html #### + output$networkCocit.fig <- downloadHandler( + filename = "network.html", + content <- function(con) { + savenetwork(con) + }, + contentType = "html" + ) + ### Historiograph ---- output$histPlot <- renderPlot({ ## Historiograph @@ -968,40 +1238,72 @@ server <- function(input, output, session) { }) - output$colPlot <- renderPlot({ + ### SOCIAL STRUCTURE #### + ### Collaboration network ---- + output$colPlot <- renderVisNetwork({ - ## Collaboration network input$applyCol - - isolate( - if (input$colField=="COL_CO" & input$collayout=="worldmap"){ - values$colmap=countrycollaboration(values$M,label=FALSE,edgesize=input$coledgesize/2,min.edges=input$coledges.min) - plot(values$colmap$g) - - }else{values <- socialStructure(input,values)} - ) - }, height = 750)#, width = 750 - - output$network.col <- downloadHandler( - filename = "Collaboration_network.net", - content <- function(file) { - igraph::write.graph(values$colnet$graph_pajek,file=file, format="pajek") - #rio::export(values$M, file=file) + t = tempfile();pdf(file=t) #### trick to hide igraph plot + values <- isolate(socialStructure(input,values)) + dev.off();file.remove(t) ### end of trick + + isolate(values$network<-igraph2vis(g=values$colnet$graph,curved=(input$soc.curved=="Yes"), + labelsize=input$collabelsize, opacity=input$colAlpha,type=input$collayout)) + + isolate(values$network$VIS) + + }) + + output$network.col <- downloadHandler( + filename = "Collaboration_network.net", + content <- function(file) { + igraph::write.graph(values$colnet$graph_pajek,file=file, format="pajek") + #rio::export(values$M, file=file) + }, + contentType = "net" + ) + + output$colTable <- DT::renderDT({ + + colData=values$colnet$cluster_res + names(colData)=c("Node", "Cluster", "Btw Centrality") + + DT::datatable(colData, escape = FALSE, rownames = FALSE, extensions = c("Buttons"), filter = 'top', + options = list(pageLength = 50, dom = 'Bfrtip', + buttons = c('pageLength','copy','excel', 'pdf', 'print'), + lengthMenu = list(c(10,25,50,-1),c('10 rows', '25 rows', '50 rows','Show all')), + columnDefs = list(list(className = 'dt-center', targets = 0:(length(names(colData))-1))))) %>% + formatStyle(names(colData), backgroundColor = 'white') + #return(Data) + + }) + ### save coc network image as html #### + output$networkCol.fig <- downloadHandler( + filename = "network.html", + content <- function(con) { + savenetwork(con) }, - contentType = "net" + contentType = "html" ) - output$colTable <- DT::renderDT({ + ### WPPlot ---- + output$WMPlot<- renderPlot({ + + #input$applyWM + values$WMmap=countrycollaboration(values$M,label=FALSE,edgesize=input$WMedgesize/2,min.edges=input$WMedges.min) + plot(values$WMmap$g) + #isolate(values$WMmap=countrycollaboration(values$M,label=FALSE,edgesize=input$WMedgesize/2,min.edges=input$WMedges.min)) + #isolate(plot(values$WMmap$g)) + + },height = 750)#, width = 750 + + output$WMTable <- DT::renderDT({ + + colData=values$WMmap$tab + colData=colData[,c(1,2,9)] + names(colData)=c("From","To","Frequency") - if (input$collayout!="worldmap"){ - colData=values$colnet$cluster_res - names(colData)=c("Node", "Cluster", "Btw Centrality") - }else{ - colData=values$colmap$tab - colData=colData[,c(1,2,9)] - names(colData)=c("From","To","Frequency") - } DT::datatable(colData, escape = FALSE, rownames = FALSE, extensions = c("Buttons"), filter = 'top', options = list(pageLength = 50, dom = 'Bfrtip', buttons = c('pageLength','copy','excel', 'pdf', 'print'), @@ -1010,10 +1312,9 @@ server <- function(input, output, session) { formatStyle(names(colData), backgroundColor = 'white') #return(Data) - }) + }) - - # common functions + ### COMMON FUNCTIONS #### emptyPlot<-function(errortext){ g=ggplot()+ @@ -1022,20 +1323,149 @@ server <- function(input, output, session) { plot(g) } - hindex<-function(input,value){ + count.duplicates <- function(DF){ + x <- do.call('paste', c(DF, sep = '\r')) + ox <- order(x) + rl <- rle(x[ox]) + cbind(DF[ox[cumsum(rl$lengths)],,drop=FALSE],count = rl$lengths) + + } + + initial <- function(values){ + values$results=list("NA") + values$log="working..." + values$load="FALSE" + values$field="NA" + values$citField=values$colField=values$citSep="NA" + values$NetWords=values$NetRefs=values$ColNetRefs=matrix(NA,1,1) + values$Title="Network" + values$Histfield="NA" + values$histlog="working..." + values$kk=0 + values$histsearch="NA" + values$citShortlabel="NA" + values$S=list("NA") + + return(values) + } + + + ### ANALYSIS FUNCTIONS #### + ### Descriptive functions ---- + Hindex_plot <- function(values, type){ + + hindex<-function(values,type){ + + switch(type, + author={ + AU=gsub(",","",names(tableTag(values$M,"AU"))) + values$H=Hindex(values$M, field = "author", elements = AU, sep = ";", years=100)$H + }, + source={ + SO=names(sort(table(values$M$SO),decreasing = TRUE)) + values$H=Hindex(values$M, field = "source", elements = SO, sep = ";", years=100)$H + } + ) + + return(values) + } + + values<-hindex(values, type = type) + + xx=values$H + if (type=="author"){ + K=input$Hkauthor + measure=input$HmeasureAuthors + title="Authors' Impact" + xn="Authors" + } else { + K=input$Hksource + measure=input$HmeasureSources + title="Sources' Impact" + xn="Sources" + } + if (K>dim(xx)[1]){ + k=dim(xx)[1] + } else {k=K} + + switch(measure, + h={m=2}, + g={m=3}, + m={m=4}, + tc={m=5} + ) + xx=xx[order(-xx[,m]),] + xx=xx[1:k,c(1,m)] + + g=ggplot2::ggplot(data=xx, aes(x=xx[,1], y=xx[,2], fill=-xx[,2])) + + #geom_bar(stat="identity", fill="steelblue")+ + geom_bar(stat="identity")+ + scale_fill_continuous(type = "gradient")+ + scale_x_discrete(limits = rev((xx[,1])))+ + labs(title=title, x = xn)+ + labs(y = names(values$H)[m])+ + theme_minimal() + + guides(fill=FALSE)+ + coord_flip() + + res<-list(values=values,g=g) + return(res) + } + + descriptive <- function(values,type){ + if (values$results[[1]]=="NA"){ + values$results=biblioAnalysis(values$M)} + if (values$S[[1]][1]=="NA"){ + values$S=summary(values$results,k=Inf,verbose=FALSE)} - switch(input$unitH, - author={ - AU=gsub(",","",names(tableTag(values$M,"AU"))) - values$H=Hindex(values$M, field = "author", elements = AU, sep = ";", years=100)$H + switch(type, + "tab1"={ + #TAB=data.frame(Information=gsub("[[:digit:]]", "", S$MainInformation), Data=gsub("[^0-9]", "", S$MainInformation)) + TAB=data.frame(values$S$MainInformationDF) + #cat(S$MainInformation) + }, + "tab2"={ + + TAB=values$S$AnnualProduction + names(TAB)=c("Year","Articles") + #print(S$AnnualProduction) + #cat("\n\n") + #cat("Annual Growth Rate ",round(S$AnnualGrowthRate, digits=2),"%") + }, + "tab3"={ + TAB=values$S$MostProdAuthors + names(TAB)=c("Authors","Articles","Authors-Frac","Articles Fractionalized") + #print(S$MostProdAuthors) + }, + "tab4"={ + TAB=values$S$MostCitedPapers + names(TAB)=c("Paper", "Total Citations","TC per Year") + #print(S$MostCitedPapers) + }, + "tab5"={ + TAB=values$S$MostProdCountries + #print(S$MostProdCountries) + }, + "tab6"={ + TAB=values$S$TCperCountries + #print(S$TCperCountries) + }, + "tab7"={ + TAB=values$S$MostRelSources + #print(S$MostRelSources) + }, + + "tab10"={ + TAB<-mapworld(values$M)$tab }, - source={ - SO=names(sort(table(values$M$SO),decreasing = TRUE)) - values$H=Hindex(values$M, field = "source", elements = SO, sep = ";", years=100)$H + "tab11"={ + TAB=as.data.frame(values$results$Affiliations,stringsAsFactors = FALSE) + names(TAB)=c("Affiliations", "Articles") } ) - - return(values) + values$TAB=TAB + res=list(values=values,TAB=TAB) + return(res) } wordlist <- function(M, Field, n, measure){ @@ -1056,6 +1486,7 @@ server <- function(input, output, session) { Words=data.frame(Terms=names(v)[1:n], Frequency=(as.numeric(v)[1:n])) W=Words switch(measure, + identity={}, sqrt={W$Frequency=sqrt(W$Frequency)}, log={W$Frequency=log(W$Frequency+1)}, log10={W$Frequency=log10(W$Frequency+1)} @@ -1065,54 +1496,6 @@ server <- function(input, output, session) { return(results) } - cocNetwork <- function(input,values){ - - n = input$Nodes - label.n = input$Labels - if ((input$field %in% names(values$M))){ - - if ((dim(values$NetWords)[1])==1 | !(input$field==values$field)){ - - values$field=input$field - - switch(input$field, - ID={ - values$NetWords <- biblioNetwork(values$M, analysis = "co-occurrences", network = "keywords", sep = ";") - values$Title= "Keywords Plus Network" - }, - DE={ - values$NetWords <- biblioNetwork(values$M, analysis = "co-occurrences", network = "author_keywords", sep = ";") - values$Title= "Authors' Keywords network" - }, - TI={ - if(!("TI_TM" %in% names(values$M))){values$M=termExtraction(values$M,Field="TI",verbose=FALSE)} - values$NetWords <- biblioNetwork(values$M, analysis = "co-occurrences", network = "titles", sep = ";") - values$Title= "Title Words network" - }, - AB={ - if(!("AB_TM" %in% names(values$M))){values$M=termExtraction(values$M,Field="AB",verbose=FALSE)} - values$NetWords <- biblioNetwork(values$M, analysis = "co-occurrences", network = "abstracts", sep = ";") - values$Title= "Abstract Words network" - }) - - } - - if (n>dim(values$NetWords)[1]){n=dim(values$NetWords)[1]} - if (label.n>n){label.n=n} - if (input$normalize=="none"){normalize=NULL}else{normalize=input$normalize} - if (input$label.cex=="Yes"){label.cex=TRUE}else{label.cex=FALSE} - if (input$size.cex=="Yes"){size.cex=TRUE}else{size.cex=FALSE} - if (input$coc.curved=="Yes"){curved=TRUE}else{curved=FALSE} - - #par(bg="grey92", mar=c(0,0,0,0)) - values$cocnet=networkPlot(values$NetWords, normalize=normalize,n = n, Title = values$Title, type = input$layout, - size.cex=size.cex, size=input$size , remove.multiple=F, edgesize = input$edgesize, labelsize=input$labelsize,label.cex=label.cex, - label.n=label.n,edges.min=input$edges.min,label.color = F, curved=curved,alpha=input$cocAlpha) - }else{ - emptyPlot("Selected field is not included in your data collection") - } - } - mapworld <- function(M){ M=metaTagExtraction(M,"AU_CO") CO=as.data.frame(tableTag(M,"AU_CO"),stringsAsFactors = FALSE) @@ -1162,7 +1545,8 @@ server <- function(input, output, session) { results=list(g=g,tab=tab) return(results) } - + + ### Strucutre fuctions ---- CAmap <- function(input, values){ if ((input$CSfield %in% names(values$M))){ @@ -1216,6 +1600,73 @@ server <- function(input, output, session) { return(values) } + historiograph <- function(input,values){ + + if (input$histsearch=="FAST"){ + min.cit=quantile(values$M$TC,0.75) + }else{min.cit=1} + + if (values$Histfield=="NA" | values$histsearch!=input$histsearch){ + values$histResults <- histNetwork(values$M, min.citations=min.cit, sep = ";") + values$Histfield="done" + values$histsearch=input$histsearch + } + + values$histlog<- capture.output(values$histPlot <- histPlot(values$histResults, n=input$histNodes, size.cex=TRUE , size =input$histsize, labelsize = input$histlabelsize, arrowsize = 0.5)) + return(values) + } + + + ### Network functions ---- + cocNetwork <- function(input,values){ + + n = input$Nodes + label.n = input$Labels + if ((input$field %in% names(values$M))){ + + if ((dim(values$NetWords)[1])==1 | !(input$field==values$field)){ + + values$field=input$field + + switch(input$field, + ID={ + values$NetWords <- biblioNetwork(values$M, analysis = "co-occurrences", network = "keywords", sep = ";") + values$Title= "Keywords Plus Network" + }, + DE={ + values$NetWords <- biblioNetwork(values$M, analysis = "co-occurrences", network = "author_keywords", sep = ";") + values$Title= "Authors' Keywords network" + }, + TI={ + if(!("TI_TM" %in% names(values$M))){values$M=termExtraction(values$M,Field="TI",verbose=FALSE)} + values$NetWords <- biblioNetwork(values$M, analysis = "co-occurrences", network = "titles", sep = ";") + values$Title= "Title Words network" + }, + AB={ + if(!("AB_TM" %in% names(values$M))){values$M=termExtraction(values$M,Field="AB",verbose=FALSE)} + values$NetWords <- biblioNetwork(values$M, analysis = "co-occurrences", network = "abstracts", sep = ";") + values$Title= "Abstract Words network" + }) + + } + + if (n>dim(values$NetWords)[1]){n=dim(values$NetWords)[1]} + if (label.n>n){label.n=n} + if (input$normalize=="none"){normalize=NULL}else{normalize=input$normalize} + if (input$label.cex=="Yes"){label.cex=TRUE}else{label.cex=FALSE} + if (input$size.cex=="Yes"){size.cex=TRUE}else{size.cex=FALSE} + if (input$coc.curved=="Yes"){curved=TRUE}else{curved=FALSE} + + #par(bg="grey92", mar=c(0,0,0,0)) + values$cocnet=networkPlot(values$NetWords, normalize=normalize,n = n, Title = values$Title, type = input$layout, + size.cex=size.cex, size=input$size , remove.multiple=F, edgesize = input$edgesize, labelsize=input$labelsize,label.cex=label.cex, + label.n=label.n,edges.min=input$edges.min,label.color = F, curved=curved,alpha=input$cocAlpha) + }else{ + emptyPlot("Selected field is not included in your data collection") + } + return(values) + } + intellectualStructure <- function(input,values){ n = input$citNodes label.n = input$citLabels @@ -1258,22 +1709,6 @@ server <- function(input, output, session) { return(values) } - historiograph <- function(input,values){ - - if (input$histsearch=="FAST"){ - min.cit=quantile(values$M$TC,0.75) - }else{min.cit=1} - - if (values$Histfield=="NA" | values$histsearch!=input$histsearch){ - values$histResults <- histNetwork(values$M, min.citations=min.cit, sep = ";") - values$Histfield="done" - values$histsearch=input$histsearch - } - - values$histlog<- capture.output(values$histPlot <- histPlot(values$histResults, n=input$histNodes, size.cex=TRUE , size =input$histsize, labelsize = input$histlabelsize, arrowsize = 0.5)) - return(values) - } - socialStructure<-function(input,values){ n = input$colNodes label.n = input$colLabels @@ -1337,14 +1772,6 @@ server <- function(input, output, session) { country.prod <- dplyr::left_join( map.world, CO, by = c('region' = 'Tab')) - #tab=data.frame(country.prod %>% - # dplyr::group_by(region) %>% - # dplyr::summarise(Freq=mean(Freq))) - - #tab=tab[!is.na(tab$Freq),] - - #tab=tab[order(-tab$Freq),] - breaks=as.numeric(round(quantile(CO$Freq,c(0.2,0.4,0.6,0.8,1)))) names(breaks)=breaks breaks=log(breaks) @@ -1392,30 +1819,70 @@ server <- function(input, output, session) { results=list(g=g,tab=tab) return(results) } + ### visNetwork tools ---- + netLayout <- function(type){ + switch(type, + auto={l <- "layout_nicely"}, + circle={l <- "layout_in_circle"}, + mds={l <- "layout_with_mds"}, + star={l <- "layout_as_star"}, + + sphere={l <- "layout_on_sphere"}, + fruchterman={l <- "layout_with_fr"}, + kamada={l <- "layout_with_kk"} + ) + return(l) + } - count.duplicates <- function(DF){ - x <- do.call('paste', c(DF, sep = '\r')) - ox <- order(x) - rl <- rle(x[ox]) - cbind(DF[ox[cumsum(rl$lengths)],,drop=FALSE],count = rl$lengths) - + savenetwork <- function(con){ + vn=values$network$vn + visNetwork(nodes = vn$nodes, edges = vn$edges, type="full", smooth=TRUE, physics=FALSE, height = "2000px",width = "2000px" ) %>% + visNodes(shape="box", font=list(color="black"),scaling=list(label=list(enables=TRUE))) %>% + visIgraphLayout(layout = values$network$l) %>% + visEdges(smooth = values$network$curved) %>% + visOptions(highlightNearest =list(enabled = T, hover = T, degree=1), nodesIdSelection = T) %>% + visInteraction(dragNodes = TRUE, navigationButtons = TRUE, hideEdgesOnDrag = TRUE) %>% visExport() %>% + visPhysics(enabled = FALSE) %>% visSave(con) } - initial<-function(values){ - values$results=list("NA") - values$log="working..." - values$load="FALSE" - values$field="NA" - values$citField=values$colField=values$citSep="NA" - values$NetWords=values$NetRefs=values$ColNetRefs=matrix(NA,1,1) - values$Title="Network" - values$Histfield="NA" - values$histlog="working..." - values$kk=0 - values$histsearch="NA" - values$citShortlabel="NA" + igraph2vis<-function(g,curved,labelsize,opacity,type){ - return(values) + LABEL=igraph::V(g)$name + + LABEL[igraph::V(g)$labelsize==0]="" + + vn <- toVisNetworkData(g) + + vn$nodes$label=LABEL + vn$edges$num=1 + Min=min(vn$nodes$font.size) + Max=max(vn$nodes$font.size) + if (Max>Min){ + size=(vn$nodes$font.size-Min)/(Max-Min)*10*labelsize+10} else {size=5*labelsize} + vn$nodes$font.size=size + + ## opacity + vn$nodes$color=adjustcolor(vn$nodes$color,alpha=min(c(opacity+0.2,1))) + vn$edges$color=adjustcolor(vn$edges$color,alpha=opacity) + + ## removing multiple edges + vn$edges=unique(vn$edges) + + ## labelsize + size=(vn$nodes$font.size-min(vn$nodes$font.size))/(max(vn$nodes$font.size,na.rm = T)-min(vn$nodes$font.size))*10*labelsize+10 + vn$nodes$font.size=size + l<-netLayout(type) + + ### TO ADD SHAPE AND FONT COLOR OPTIONS + + VIS<-visNetwork(nodes = vn$nodes, edges = vn$edges, type="full", smooth=TRUE, physics=FALSE) %>% + visNodes(shape="box", font=list(color="black"),scaling=list(label=list(enables=TRUE))) %>% + visIgraphLayout(layout = l) %>% + visEdges(smooth = curved) %>% + visOptions(highlightNearest =list(enabled = T, hover = T, degree=1), nodesIdSelection = T) %>% + visInteraction(dragNodes = TRUE, navigationButtons = TRUE, hideEdgesOnDrag = TRUE) + values$COCVIS=VIS + return(list(VIS=VIS,vn=vn, type=type, l=l, curved=curved)) } } ## End of Server \ No newline at end of file diff --git a/inst/biblioshiny/ui.R b/inst/biblioshiny/ui.R index ac9fbacf..42e89345 100644 --- a/inst/biblioshiny/ui.R +++ b/inst/biblioshiny/ui.R @@ -10,15 +10,15 @@ if (!(require(wordcloud2))){install.packages("wordcloud2")} if (!require(colourpicker)){install.packages("colourpicker")} if (!require(treemap)){install.packages("treemap")} if (!require(ggmap)){install.packages("ggmap"); require(ggmap, quietly=TRUE)} +if (!require(visNetwork)){install.packages("visNetwork"); require(visNetwork, quietly=TRUE)} require(Matrix, quietly = TRUE) - # Main NavBar ---- options(spinner.size=1, spinner.type=5) -ui <- navbarPage("biblioshiny: The shiny app for bibliometrix R-package", +ui <- navbarPage("biblioshiny for bibliometrix", theme=shinythemes::shinytheme("flatly"), - + ### WELCOME PAGE ---- tabPanel("Welcome", fluidRow( @@ -147,127 +147,312 @@ tabPanel( ), -### Descriptive Analysis PAGE ---- -navbarMenu("Descriptive Analysis", + +### DATASET MENU ---- +navbarMenu("Dataset", + " ", + " ", + tabPanel("Main Information", + sidebarLayout( + sidebarPanel(width=3), + mainPanel( + shinycssloaders::withSpinner(DT::DTOutput(outputId = "MainInfo")) + ) + )), + tabPanel("Annual Scientific Production", + sidebarLayout( + sidebarPanel(width=3), + mainPanel( + tabsetPanel(type = "tabs", + tabPanel("Plot", + shinycssloaders::withSpinner(plotOutput(outputId = "AnnualProdPlot")) + ), + tabPanel("Table", + shinycssloaders::withSpinner(DT::DTOutput("AnnualProdTable")) + )) + ) + ) + ) +), + +### SOURCES MENU ---- +navbarMenu("Sources", " ", " ", - "Impact & Productivity", - tabPanel("Tables", + #### MOST RELEVANT SOURCES ---- + tabPanel("Most Relevant Sources", + sidebarLayout( + sidebarPanel(width=3, + " ", + " ", + h4(em(strong("Graphical Parameters: "))), + " ", + numericInput("MostRelSourcesK", + label=("Number of Sources"), + value = 20) + ), + mainPanel( + tabsetPanel(type = "tabs", + tabPanel("Plot", + shinycssloaders::withSpinner(plotOutput(outputId = "MostRelSourcesPlot")) + ), + tabPanel("Table", + shinycssloaders::withSpinner(DT::DTOutput("MostRelSourcesTable")) + )) + ) + ) + ), + ### BRADFORD LAW ---- + tabPanel("Bradford's law", + + sidebarLayout( + sidebarPanel(width=3, + helpText("dddd") + ), + mainPanel( + tabsetPanel(type = "tabs", + tabPanel("Plot", + shinycssloaders::withSpinner(plotOutput(outputId = "bradfordPlot")) + ), + tabPanel("Table", + shinycssloaders::withSpinner(DT::DTOutput("bradfordTable")) + )) + ) + + ) + ), + ### SOURCE HINDEX MENU ---- + tabPanel("Source's H-index", sidebarLayout( + sidebarPanel(width=3, + " ", + " ", + actionButton("applyHsource", "Apply!"), + " ", + " ", + h4(em(strong("Graphical Parameters: "))), + " ", + selectInput("HmeasureSources", + label = "Impact measure", + choices = c("H-Index"="h", + "G-Index"="g", + "M-Index"="m", + "Total Citation"="tc"), + selected = "h"), + " ", + numericInput("Hksource", + label=("Number of sources"), + value = 20) + ), + mainPanel( + + tabsetPanel(type = "tabs", + tabPanel("Plot", + shinycssloaders::withSpinner(plotOutput(outputId = "SourceHindexPlot")) + ), + tabPanel("Table", + shinycssloaders::withSpinner(DT::DTOutput(outputId = "SourceHindexTable")) + )) + ) + ) + ), + ### SOURCE DYNAMICS MENU ---- + tabPanel("Source Dynamics", + + sidebarLayout( + # Sidebar with a slider and selection inputs sidebarPanel(width=3, - selectInput("summary_type", - label = "Result:", - choices = c("Main Information about data"="tab1", - "Annual Scientific Production"="tab2", - "Corresponding Author's Countries"="tab5", - "Country Scientific Production"="tab10", - "Most Cited Papers"="tab4", - "Most Cited References"="tab9", - "Most Cited Countries"="tab6", - "Most Productive Authors"="tab3", - "Most Relevant Keywords"="tab8", - "Most Relevant Sources"="tab7"), - selected = "tab1"), + selectInput("cumSO", "Occurrences", + choices = c("Cumulate" = "Cum", + "Per year" = "noCum"), + selected = "noCum"), + selectInput("SOse", "Confidence Interval", + choices = c("Yes" = "Yes", + "No" = "No"), + selected = "No"), + hr(), + sliderInput("topSO", label = "Number of Sources", min = 1, max = 50, step = 1, value = 5) + + #uiOutput("sliderKwYears") + ), + + # + mainPanel( + tabsetPanel(type = "tabs", + tabPanel("Plot", + shinycssloaders::withSpinner(plotOutput(outputId = "soGrowthPlot")) + ), + tabPanel("Table", + shinycssloaders::withSpinner(DT::DTOutput(outputId = "soGrowthtable")) + )) - conditionalPanel(condition = "(input.summary_type != 'tab1') & (input.summary_type != 'tab2') & (input.summary_type != 'tab9')", - numericInput("kk", - label=("Number of results"), - value = 20)), - conditionalPanel(condition = "input.summary_type == 'tab9'", - selectInput(inputId = "sep", - label = "Field separator character", - choices = c("semicolon" = ";", - "dot and 2 spaces" = ". ", - "dot and 3 spaces" = ". ", - "comma" = ","), - selected = ";")), - selectInput('save_summary', 'Save as:', choices = c('No, thanks!' = 'no_thanks', 'txt file' = 'txt')), - conditionalPanel(condition = "input.save_summary == 'txt'", - downloadButton("results.txt", "Save")) + ) + )) + +), +### AUTHORS MENU ---- +navbarMenu("Authors", + " ", + " ", + ### MOST RELEVANT AUTHORS ---- + "Authors", + tabPanel("Most Relevant Authors", + sidebarLayout( + sidebarPanel(width=3, + " ", + " ", + h4(em(strong("Graphical Parameters: "))), + " ", + numericInput("MostRelAuthorsK", + label=("Number of Authors"), + value = 20) ), mainPanel( - shinycssloaders::withSpinner(DT::DTOutput(outputId = "summary")) - #shinycssloaders::withSpinner(verbatimTextOutput("summary")) + tabsetPanel(type = "tabs", + tabPanel("Plot", + shinycssloaders::withSpinner(plotOutput(outputId = "MostRelAuthorsPlot")) + ), + tabPanel("Table", + shinycssloaders::withSpinner(DT::DTOutput("MostRelAuthorsTable")) + )) ) ) ), - tabPanel("Plots", + ### AUTHOR'S PRODUCTION OVER TIME ---- + tabPanel("Author's Production over Time", sidebarLayout( - - sidebarPanel(width=3, - - selectInput("plot_type", - label = "Choose the plot", - choices = c("Annual Scientific Production"= "production", - "Corresponding Author's Countries"="countries", - "Country Scientific Production"="mapworld", - "Most Productive Authors"="authors", - "Average Article Citations per Year"="articleTC", - "Average Total Citation per Year"="annualTC"), - selected = "production"), - - conditionalPanel(condition = "input.plot_type == 'authors'", - numericInput("k", - label=("Number of results"), - value = 20) - ), - conditionalPanel(condition = "input.plot_type == 'countries'", - numericInput("k", - h3("Number of results"), - value = 20) - ) - + " ", + " ", + h4(em(strong("Graphical Parameters: "))), + " ", + numericInput("TopAuthorsProdK", + label=("Number of Authors"), + value = 20) ), mainPanel( - shinycssloaders::withSpinner(plotOutput(outputId = "summaryPlots")) + tabsetPanel(type = "tabs", + tabPanel("Plot", + shinycssloaders::withSpinner(plotOutput(outputId = "TopAuthorsProdPlot")) + ), + tabPanel("Table", + shinycssloaders::withSpinner(DT::DTOutput("TopAuthorsProdTable")) + )) ) - ) ), - tabPanel("H-index", + + ### LOTKA LAW ---- + tabPanel("Lotka's law", + sidebarLayout( + sidebarPanel(width=3, + helpText("dddd") + ), + mainPanel( + tabsetPanel(type = "tabs", + tabPanel("Plot", + shinycssloaders::withSpinner(plotOutput(outputId = "lotkaPlot")) + ), + tabPanel("Table", + shinycssloaders::withSpinner(DT::DTOutput("lotkaTable")) + )) + ) - + ) + ), + ### AUTHOR HINDEX ---- + tabPanel("Author's H-index", + sidebarLayout( sidebarPanel(width=3, - actionButton("applyH", "Apply!"), - hr(), - selectInput("unitH", - label = "Unit of Analysis", - choices = c("Authors"= "author", - "Sources"="source"), - selected = "author") - ), + " ", + " ", + actionButton("applyHauthor", "Apply!"), + " ", + " ", + h4(em(strong("Graphical Parameters: "))), + " ", + selectInput("HmeasureAuthors", + label = "Impact measure", + choices = c("H-Index"="h", + "G-Index"="g", + "M-Index"="m", + "Total Citation"="tc"), + selected = "h"), + " ", + numericInput("Hkauthor", + label=("Number of authors"), + value = 20) + ), mainPanel( - shinycssloaders::withSpinner(DT::DTOutput(outputId = "hindexTable")) + + tabsetPanel(type = "tabs", + tabPanel("Plot", + shinycssloaders::withSpinner(plotOutput(outputId = "AuthorHindexPlot")) + ), + tabPanel("Table", + shinycssloaders::withSpinner(DT::DTOutput(outputId = "AuthorHindexTable")) + )) ) ) ), " ", " ", - "Laws", - tabPanel("Bradford's law", - + "Affiliations", + ### MOST RELEVANT AFFILIATION ---- + tabPanel("Most Relevant Affiliations", sidebarLayout( sidebarPanel(width=3, - helpText("dddd") + " ", + " ", + h4(em(strong("Graphical Parameters: "))), + " ", + numericInput("MostRelAffiliationsK", + label=("Number of Affiliations"), + value = 20) ), mainPanel( tabsetPanel(type = "tabs", tabPanel("Plot", - shinycssloaders::withSpinner(plotOutput(outputId = "bradfordPlot")) + shinycssloaders::withSpinner(plotOutput(outputId = "MostRelAffiliationsPlot")) ), tabPanel("Table", - shinycssloaders::withSpinner(DT::DTOutput("bradfordTable")) + shinycssloaders::withSpinner(DT::DTOutput("MostRelAffiliationsTable")) )) ) - + ) + ), + " ", + " ", + "Countries", + ### CORRESP AUTHOR'S COUNTRY ---- + tabPanel("Corresponding Author's Country", + sidebarLayout( + sidebarPanel(width=3, + " ", + " ", + h4(em(strong("Graphical Parameters: "))), + " ", + numericInput("MostRelCountriesK", + label=("Number of Countries"), + value = 20) + ), + mainPanel( + tabsetPanel(type = "tabs", + tabPanel("Plot", + shinycssloaders::withSpinner(plotOutput(outputId = "MostRelCountriesPlot")) + ), + tabPanel("Table", + shinycssloaders::withSpinner(DT::DTOutput("MostRelCountriesTable")) + )) ) + ) ), - tabPanel("Lotka's law", + ### COUNTRY SCIENTIFIC PRODUCTION ---- + tabPanel("Country Scientific Production", sidebarLayout( sidebarPanel(width=3, @@ -276,73 +461,274 @@ navbarMenu("Descriptive Analysis", mainPanel( tabsetPanel(type = "tabs", tabPanel("Plot", - shinycssloaders::withSpinner(plotOutput(outputId = "lotkaPlot")) + shinycssloaders::withSpinner(plotOutput(outputId = "countryProdPlot")) ), tabPanel("Table", - shinycssloaders::withSpinner(DT::DTOutput("lotkaTable")) + shinycssloaders::withSpinner(DT::DTOutput("countryProdTable")) )) ) ) ), + ### MOST CITED COUNTRIES ---- + tabPanel("Most Cited Countries", + sidebarLayout( + sidebarPanel(width=3, + " ", + " ", + h4(em(strong("Graphical Parameters: "))), + " ", + selectInput("CitCountriesMeasure", + label = "Measure", + choices = c("Total Citations"="TC", + "Average Citations per Year"="TCY"), + selected = "TC"), + " ", + numericInput("MostCitCountriesK", + label=("Number of Countries"), + value = 20) + ), + mainPanel( + tabsetPanel(type = "tabs", + tabPanel("Plot", + shinycssloaders::withSpinner(plotOutput(outputId = "MostCitCountriesPlot")) + ), + tabPanel("Table", + shinycssloaders::withSpinner(DT::DTOutput("MostCitCountriesTable")) + )) + ) + ) + ) +), +### DOCS MENU ---- +navbarMenu("Documents", " ", " ", - "Contents", - tabPanel("WordCloud", + "Documents", + ### CITED DOCS ---- + tabPanel("Most Global Cited Documents", + sidebarLayout( + sidebarPanel(width=3, + " ", + " ", + h4(em(strong("Graphical Parameters: "))), + " ", + numericInput("MostCitDocsK", + label=("Number of Documents"), + value = 20), + " ", + selectInput("CitDocsMeasure", + label = "Measure", + choices = c("Total Citations"="TC", + "Total Citations per Year"="TCY"), + selected = "TC"), + " " + ), + mainPanel( + tabsetPanel(type = "tabs", + tabPanel("Plot", + shinycssloaders::withSpinner(plotOutput(outputId = "MostCitDocsPlot")) + ), + tabPanel("Table", + shinycssloaders::withSpinner(DT::DTOutput("MostCitDocsTable")) + )) + ) + ) + ), + tabPanel("Most Local Cited Documents", + sidebarLayout( + sidebarPanel(width=3, + " ", + " ", + h4(em(strong("Graphical Parameters: "))), + " ", + numericInput("MostLocCitDocsK", + label=("Number of Documents"), + value = 20), + " ", + selectInput(inputId = "LocCitSep", + label = "Field separator character", + choices = c(";" = ";", + ". " = ". ", + "," = ","), + selected = ";"), + " " + ), + mainPanel( + tabsetPanel(type = "tabs", + tabPanel("Plot", + shinycssloaders::withSpinner(plotOutput(outputId = "MostLocCitDocsPlot")) + ), + tabPanel("Table", + shinycssloaders::withSpinner(DT::DTOutput("MostLocCitDocsTable")) + )) + ) + ) + ), + ### CITED REFERENCES ---- + " ", + " ", + "Cited References", - sidebarLayout( - # Sidebar with a slider and selection inputs - sidebarPanel(width=3, - selectInput("summaryTerms", "Field", - choices = c("Keywords Plus" = "ID", - "Author's keywords" = "DE", - "Titles" = "TI", - "Abstracts" = "AB"), - selected = "ID"), - hr(), - sliderInput("n_words", label = "Number of words", min = 10, max = 200, step = 5, value = 50), - selectInput("measure", "Word occurrence measure", - choices = c("Frequency" = "freq", - "Square root" = "sqrt", - "Log" = "log", - "Log10" = "log10"), - selected = "freq"), - selectInput("wcShape", "Shape", - choices = c("Circle" = "circle", - "Cardiod" = "cardioid", - "Diamond" = "diamond", - "Pentagon" = "pentagon", - "Star" = "star", - "Triangle-forward" = "triangle-forward" - ,"Triangle" = "triangle"), - selected = "circle"), - selectInput("font", label = "Font type", - choices = c("Impact", "Comic Sans MS (No plz!)" = "Comic Sans MS", - "Arial", "Arial Black", "Tahoma", "Verdana", "Courier New", - "Georgia", "Times New Roman", "Andale Mono")), - selectInput("wcCol", "Text colors", - choices = c("Random Dark" = "random-dark", - "Random Light" = "random-light"), - selected = "random-dark"), - colourpicker::colourInput("wcBGCol", label= "Backgroud color",value="white", showColour = "background", returnName=TRUE), - sliderInput("scale", label = "Font size", min=0.2,max=5,step=0.1,value=1), - sliderInput("ellipticity", label = "Ellipticity", min=0,max=1,step=0.05,value=0.65), - sliderInput("padding", label = "Padding", min = 0, max = 5, value = 1, step = 1), - sliderInput("rotate", label = "Rotate", min = 0, max = 20, value = 0, step = 1) - ), - - # Show Word Cloud - mainPanel( - tabsetPanel(type = "tabs", - tabPanel("Plot", - wordcloud2::wordcloud2Output("wordcloud", height = "600px") - ), - tabPanel("Table", - shinycssloaders::withSpinner(DT::DTOutput("wordTable")) - )) - + tabPanel("Most Local Cited References", + sidebarLayout( + sidebarPanel(width=3, + " ", + " ", + h4(em(strong("Graphical Parameters: "))), + " ", + numericInput("MostCitRefsK", + label=("Number of Documents"), + value = 20), + " ", + selectInput(inputId = "CitRefsSep", + label = "Field separator character", + choices = c(";" = ";", + ". " = ". ", + "," = ","), + selected = ";") + ), + mainPanel( + tabsetPanel(type = "tabs", + tabPanel("Plot", + shinycssloaders::withSpinner(plotOutput(outputId = "MostCitRefsPlot")) + ), + tabPanel("Table", + shinycssloaders::withSpinner(DT::DTOutput("MostCitRefsTable")) + )) + ) ) - )), + ), + ### Reference Spectroscopy ---- + tabPanel("Reference Spectroscopy", + sidebarLayout( + + sidebarPanel(width=3, + " ", + " ", + h4(em(strong("Graphical Parameters: "))), + " ", + sliderInput("sliderYears", + label = "Timespan", + min = 1700, + max = as.numeric(substr(Sys.Date(),1,4)), + step = 10, sep="", + value = c(1700, as.numeric(substr(Sys.Date(),1,4))) + ), + + selectInput(inputId = "rpysSep", + label = "Field separator character", + choices = c(";" = ";", + ". " = ". ", + "," = ","), + selected = ";") + + ), + mainPanel( + tabsetPanel(type = "tabs", + tabPanel("Graph", + withSpinner(plotOutput(outputId = "rpysPlot"))), + tabPanel("RPY Table", + shinycssloaders::withSpinner(DT::DTOutput( + outputId = "rpysTable"))), + tabPanel("Cited References Table", + shinycssloaders::withSpinner(DT::DTOutput( + outputId = "crTable"))) + ) + ))), + ### WORDS MENU ---- + " ", + " ", + "Words", + + ### MOST REL WORDS ---- + tabPanel("Most Relevant Words", + + sidebarLayout( + # Sidebar with a slider and selection inputs + sidebarPanel(width=3, + selectInput("MostRelWords", "Field", + choices = c("Keywords Plus" = "ID", + "Author's keywords" = "DE", + "Titles" = "TI", + "Abstracts" = "AB"), + selected = "ID"), + hr(), + sliderInput("MostRelWordsN", label = "Number of words", min = 2, max = 50, step = 1, value = 10) + + ), + + # Show Word Cloud + mainPanel( + tabsetPanel(type = "tabs", + tabPanel("Plot", + withSpinner(plotOutput(outputId = "MostRelWordsPlot")) + ), + tabPanel("Table", + shinycssloaders::withSpinner(DT::DTOutput("MostRelWordsTable")) + )) + + ) + )), + + ### WORDCLOUD ---- + tabPanel("WordCloud", + + sidebarLayout( + # Sidebar with a slider and selection inputs + sidebarPanel(width=3, + selectInput("summaryTerms", "Field", + choices = c("Keywords Plus" = "ID", + "Author's keywords" = "DE", + "Titles" = "TI", + "Abstracts" = "AB"), + selected = "ID"), + hr(), + sliderInput("n_words", label = "Number of words", min = 10, max = 200, step = 5, value = 50), + selectInput("measure", "Word occurrence measure", + choices = c("Frequency" = "freq", + "Square root" = "sqrt", + "Log" = "log", + "Log10" = "log10"), + selected = "freq"), + selectInput("wcShape", "Shape", + choices = c("Circle" = "circle", + "Cardiod" = "cardioid", + "Diamond" = "diamond", + "Pentagon" = "pentagon", + "Star" = "star", + "Triangle-forward" = "triangle-forward" + ,"Triangle" = "triangle"), + selected = "circle"), + selectInput("font", label = "Font type", + choices = c("Impact", "Comic Sans MS (No plz!)" = "Comic Sans MS", + "Arial", "Arial Black", "Tahoma", "Verdana", "Courier New", + "Georgia", "Times New Roman", "Andale Mono")), + selectInput("wcCol", "Text colors", + choices = c("Random Dark" = "random-dark", + "Random Light" = "random-light"), + selected = "random-dark"), + colourpicker::colourInput("wcBGCol", label= "Backgroud color",value="white", showColour = "background", returnName=TRUE), + sliderInput("scale", label = "Font size", min=0.2,max=5,step=0.1,value=1), + sliderInput("ellipticity", label = "Ellipticity", min=0,max=1,step=0.05,value=0.65), + sliderInput("padding", label = "Padding", min = 0, max = 5, value = 1, step = 1), + sliderInput("rotate", label = "Rotate", min = 0, max = 20, value = 0, step = 1) + ), + + # Show Word Cloud + mainPanel( + tabsetPanel(type = "tabs", + tabPanel("Plot", + wordcloud2::wordcloud2Output("wordcloud", height = "600px") + ), + tabPanel("Table", + shinycssloaders::withSpinner(DT::DTOutput("wordTable")) + )) + + ) + )), + + ### TREEMAP ---- tabPanel("TreeMap", sidebarLayout( @@ -362,7 +748,7 @@ navbarMenu("Descriptive Analysis", "Log" = "log", "Log10" = "log10"), selected = "freq"), - selectInput("treeCol", "Text colors", + selectInput("treeCol", "Text colors", choices = c("Accent" = "Accent", "Dark" = "Dark2", "Paired"= "Paired", @@ -375,7 +761,7 @@ navbarMenu("Descriptive Analysis", sliderInput("treeFont", label = "Font size", min=6,max=20,step=1,value=10) ), - # Show Word Cloud + # Show TreeMap mainPanel( tabsetPanel(type = "tabs", tabPanel("Plot", @@ -387,9 +773,8 @@ navbarMenu("Descriptive Analysis", ) )), - " ", - " ", - "Trends", + + ### WORD DYNAMICS ---- tabPanel("Word Dynamics", sidebarLayout( @@ -426,73 +811,9 @@ navbarMenu("Descriptive Analysis", )) ) - )), - - tabPanel("Source Dynamics", - - sidebarLayout( - # Sidebar with a slider and selection inputs - sidebarPanel(width=3, - selectInput("cumSO", "Occurrences", - choices = c("Cumulate" = "Cum", - "Per year" = "noCum"), - selected = "noCum"), - selectInput("SOse", "Confidence Interval", - choices = c("Yes" = "Yes", - "No" = "No"), - selected = "No"), - hr(), - sliderInput("topSO", label = "Number of Sources", min = 1, max = 50, step = 1, value = 5) - - #uiOutput("sliderKwYears") - ), - - # - mainPanel( - tabsetPanel(type = "tabs", - tabPanel("Plot", - shinycssloaders::withSpinner(plotOutput(outputId = "soGrowthPlot")) - ), - tabPanel("Table", - shinycssloaders::withSpinner(DT::DTOutput(outputId = "soGrowthtable")) - )) - - ) - )), - - tabPanel("Reference Spectroscopy", - sidebarLayout( - - sidebarPanel(width=3, - sliderInput("sliderYears", - label = "Timespan", - min = 1700, - max = as.numeric(substr(Sys.Date(),1,4)), - step = 10, sep="", - value = c(1700, as.numeric(substr(Sys.Date(),1,4))) - ), - - selectInput(inputId = "rpysSep", - label = "Field separator character", - choices = c(";" = ";", - ". " = ". ", - "," = ","), - selected = ";") - - ), - mainPanel( - tabsetPanel(type = "tabs", - tabPanel("Graph", - withSpinner(plotOutput(outputId = "rpysPlot"))), - tabPanel("RPY Table", - shinycssloaders::withSpinner(DT::DTOutput( - outputId = "rpysTable"))), - tabPanel("Cited References Table", - shinycssloaders::withSpinner(DT::DTOutput( - outputId = "crTable"))) - ) - ))) - ), + )) +), + ### CONCEPTUAL STRUCTURE ---- navbarMenu("Conceptual Structure", @@ -508,7 +829,8 @@ navbarMenu("Conceptual Structure", sidebarPanel(width=3, actionButton("applyCoc", "Apply!"), - downloadButton("network.coc", "Save the Network"), + downloadButton("network.coc", "Save Pajek"), + downloadButton("networkCoc.fig", "Save Fig."), " ", " ", h4(em(strong("Network Parameters: "))), @@ -552,6 +874,7 @@ navbarMenu("Conceptual Structure", label=("Min edges"), value = 2, step = 1), + #uiOutput("Focus"), " ", h4(em(strong("Graphical Parameters: "))), " ", @@ -576,7 +899,7 @@ navbarMenu("Conceptual Structure", label = "Label size", min = 0.0, max = 10, - value = 5, + value = 2, step = 0.10), selectInput(inputId ="size.cex", @@ -609,7 +932,7 @@ navbarMenu("Conceptual Structure", mainPanel( tabsetPanel(type = "tabs", tabPanel("Graph", - withSpinner(plotOutput(outputId = "cocPlot"))), + shinycssloaders::withSpinner(visNetworkOutput("cocPlot", height = "750px",width = "1100px"))), tabPanel("Table", shinycssloaders::withSpinner(DT::DTOutput( outputId = "cocTable"))) @@ -778,11 +1101,8 @@ navbarMenu("Intellectual Structure", sidebarPanel(width=3, actionButton("applyCocit", "Apply!"), - #selectInput('save_colnet', 'Save network as:', choices = c('No, thanks!' = 'no_thanks', 'Pajek format' = 'pajek')), - #conditionalPanel(condition = "input.save_colnet == 'pajek'", - downloadButton("network.cocit", "Save the Network"), - - + downloadButton("network.cocit", "Save Pajek"), + downloadButton("networkCocit.fig", "Save Fig."), " ", " ", h4(em(strong("Network Parameters: "))), @@ -841,7 +1161,7 @@ navbarMenu("Intellectual Structure", sliderInput(inputId = "citLabels", label = "Number of labels", min = 5, - max = 100, + max = 250, value = 50), selectInput(inputId ="citlabel.cex", @@ -854,7 +1174,7 @@ navbarMenu("Intellectual Structure", label = "Label size", min = 0.0, max = 10, - value = 5, + value = 2, step = 0.10), selectInput(inputId ="citsize.cex", @@ -882,9 +1202,9 @@ navbarMenu("Intellectual Structure", ), mainPanel( tabsetPanel(type = "tabs", + tabPanel("Graph", - shinycssloaders::withSpinner(plotOutput(outputId = "cocitPlot"))), - + shinycssloaders::withSpinner(visNetworkOutput("cocitPlot", height = "750px",width = "1100px"))), tabPanel("Table", shinycssloaders::withSpinner(DT::DTOutput( outputId = "cocitTable"))) @@ -962,7 +1282,8 @@ navbarMenu("Social Structure", sidebarPanel(width=3, actionButton("applyCol", "Apply!"), - downloadButton("network.col", "Save the Network"), + downloadButton("network.col", "Save Pakek"), + downloadButton("networkCol.fig", "Save Fig."), " ", " ", @@ -1020,7 +1341,7 @@ navbarMenu("Social Structure", sliderInput(inputId = "colLabels", label = "Number of labels", min = 5, - max = 100, + max = 250, value = 50), selectInput(inputId ="collabel.cex", @@ -1033,7 +1354,7 @@ navbarMenu("Social Structure", label = "Label size", min = 0.0, max = 10, - value = 5, + value = 2, step = 0.10), selectInput(inputId ="colsize.cex", @@ -1062,7 +1383,8 @@ navbarMenu("Social Structure", mainPanel( tabsetPanel(type = "tabs", tabPanel("Graph", - shinycssloaders::withSpinner(plotOutput(outputId = "colPlot"))), + shinycssloaders::withSpinner(visNetworkOutput("colPlot", height = "750px",width = "1100px"))), + #shinycssloaders::withSpinner(plotOutput(outputId = "colPlot"))), tabPanel("Table", shinycssloaders::withSpinner(DT::DTOutput( outputId = "colTable"))) @@ -1073,8 +1395,45 @@ navbarMenu("Social Structure", ) + ), ## End of tabPanel "Social Structure" + tabPanel(title="WorldMap Collaboration", + sidebarLayout( + + sidebarPanel(width=3, + actionButton("applyWM", "Apply!"), + " ", + " ", + h4(em(strong("Network Parameters: "))), + " ", + numericInput("WMedges.min", + label=("Min edges"), + value = 2, + step = 1), + " ", + " ", + h4(em(strong("Graphical Parameters: "))), + " ", + sliderInput(inputId = "WMedgesize", + label = "Edge size", + min = 0.1, + max = 20, + value = 5) + ), + mainPanel( + tabsetPanel(type = "tabs", + tabPanel("Graph", + shinycssloaders::withSpinner(plotOutput(outputId = "WMPlot"))), + tabPanel("Table", + shinycssloaders::withSpinner(DT::DTOutput( + outputId = "WMTable"))) + ) + + #shinycssloaders::withSpinner(plotOutput(outputId = "colPlot")) + ) + + ) + ) ## End of tabPanel "Social Structure" - ), diff --git a/man/authorProdOverTime.Rd b/man/authorProdOverTime.Rd new file mode 100644 index 00000000..f3f108b6 --- /dev/null +++ b/man/authorProdOverTime.Rd @@ -0,0 +1,36 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/authorProdOverTime.R +\name{authorProdOverTime} +\alias{authorProdOverTime} +\title{Top-Authors' Productivity over the Time} +\usage{ +authorProdOverTime(M, k = 10, graph = TRUE) +} +\arguments{ +\item{M}{is a bibliographic data frame obtained by \code{\link{convert2df}} function.} + +\item{k}{is a integer. It is the number of top auhtors to analize and plot. Default is \code{k = 10}.} + +\item{graph}{is logical. If TRUE the function plots the author production over time graph. Default is \code{graph = TRE}.} +} +\value{ +The function \code{authorProdOverTime} returns a list containing two objects: +\tabular{lll}{ +\code{dfAU} \tab \tab is a data frame\cr +\code{graph} \tab \tab a ggplot object} +} +\description{ +It calculates and plots the author production (in terms of number of publications) over the time. +} +\examples{ +data(scientometrics) +res <- authorProdOverTime(scientometrics, k=10) +print(res$dfAU) +plot(res$graph) + +} +\seealso{ +\code{\link{biblioAnalysis}} function for bibliometric analysis + +\code{\link{summary}} method for class '\code{bibliometrix}' +}