Last active
August 29, 2015 14:03
-
-
Save tts/5df86b664b840c5927f9 to your computer and use it in GitHub Desktop.
Some (alt)metrics of Aalto University publications since 2010 as a Shiny application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
doi | school | ti | au | url | details_url | py | j9 | so | tc | score | mendeley | connotea | citeulike | readers_count | cited_by_gplus_count | cited_by_fbwalls_count | cited_by_posts_count | cited_by_tweeters_count | cited_by_accounts_count | cited_by_feeds_count | cited_by_videos_count | cited_by_delicious_count | cited_by_rdts_count | cited_by_forum_count | cited_by_qs_count | cited_by_rh_count | cited_by_msm_count | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
10.1001/jama.2012.347 | SCI | One vs Three Years of Adjuvant Imatinib for Operable Gastrointestinal Stromal Tumor A Randomized Trial | Joensuu, H; Eriksson, M; Hall, KS; Hartmann, JT; Pink, D; Schutte, J; Ramadori, G; Hohenberger, P; Duyster, J; Al-Batran, SE; Schlemmer, M; Bauer, S; Wardelmann, E; Sarlomo-Rikala, M; Nilsson, B; Sihto, H; Monge, OR; Bono, P; Kallio, R; Vehtari, A; Leinonen, M; Alvegard, T; Reichardt, P | http://dx.doi.org/10.1001/jama.2012.347 | http://www.altmetric.com/details.php?citation_id=670011 | 2012 | JAMA-J AM MED ASSOC | JAMA-JOURNAL OF THE AMERICAN MEDICAL ASSOCIATION | 106 | 4.75 | 52 | 0 | 1 | 53 | NA | 1 | 7 | 5 | 7 | NA | NA | NA | NA | NA | NA | 1 | NA | |
10.1002/acp.2918 | BIZ | Attention and Memory for Newspaper Advertisements: Effects of Ad-Editorial Congruency and Location | Simola, J; Kivikangas, M; Kuisma, J; Krause, CM | http://onlinelibrary.wiley.com/doi/10.1002/acp.2918/abstract | http://www.altmetric.com/details.php?citation_id=1302496 | 2013 | APPL COGNITIVE PSYCH | APPLIED COGNITIVE PSYCHOLOGY | 2 | 1.75 | 2 | 0 | 0 | 2 | NA | NA | 1 | 4 | 4 | NA | NA | NA | NA | NA | NA | NA | NA | |
10.1002/adfm.201102827 | SCI | Simplified Large-Area Manufacturing of Organic Electrochemical Transistors Combining Printing and a Self-Aligning Laser Ablation Step | Blaudeck, T; Ersman, PA; Sandberg, M; Heinz, S; Laiho, A; Liu, J; Engquist, I; Berggren, M; Baumann, RR | http://dx.doi.org/10.1002/adfm.201102827 | http://www.altmetric.com/details.php?citation_id=704569 | 2012 | ADV FUNCT MATER | ADVANCED FUNCTIONAL MATERIALS | 5 | 10 | 16 | 0 | 0 | 16 | NA | NA | 2 | 1 | 2 | NA | NA | NA | NA | NA | NA | NA | 1 | |
10.1002/adfm.201201528 | SCI | Epitaxial Ferroelectric Heterostructures with Nanocolumn-Enhanced Dynamic Properties | Tyunina, M; Yao, LD; Plekh, M; Levoska, J; van Dijken, S | http://onlinelibrary.wiley.com/resolve/doi?DOI=10.1002%2Fadfm.201201528&utm_source=dlvr.it&utm_medium=twitter | http://www.altmetric.com/details.php?citation_id=928305 | 2013 | ADV FUNCT MATER | ADVANCED FUNCTIONAL MATERIALS | 4 | 0.5 | 4 | 0 | 0 | 4 | NA | 1 | 2 | 1 | 2 | NA | NA | NA | NA | NA | NA | NA | NA | |
10.1002/adma.201100461 | CHEM | Superhydrophobic Tracks for Low-Friction, Guided Transport of Water Droplets | Mertaniemi, H; Jokinen, V; Sainiemi, L; Franssila, S; Marmur, A; Ikkala, O; Ras, RHA | http://dx.doi.org/doi:10.1002/adma.201100461 | http://www.altmetric.com/details.php?citation_id=211781 | 2011 | ADV MATER | ADVANCED MATERIALS | 29 | 9.25 | 22 | 0 | 0 | 22 | NA | NA | 3 | NA | 2 | 1 | 1 | NA | NA | NA | NA | NA | NA | |
10.1002/adma.201101888 | ELEC | Optical Interference Lithography Using Azobenzene-Functionalized Polymers for Micro- and Nanopatterning of Silicon | Kravchenko, A; Shevchenko, A; Ovchinnikov, V; Priimagi, A; Kaivola, M | http://onlinelibrary.wiley.com/resolve/doi?DOI=10.1002/adma.201101888 | http://www.altmetric.com/details.php?citation_id=240542 | 2011 | ADV MATER | ADVANCED MATERIALS | 28 | 0.25 | 24 | 0 | 2 | 26 | NA | NA | 1 | 1 | 1 | NA | NA | NA | NA | NA | NA | NA | NA | |
10.1002/adma.201103111 | SCI | Controlling Water Capture of Bioinspired Fibers with Hump Structures | Tian, XL; Chen, Y; Zheng, YM; Bai, H; Jiang, L | http://dx.doi.org/10.1002/adma.201103111 | http://www.altmetric.com/details.php?citation_id=437073 | 2011 | ADV MATER | ADVANCED MATERIALS | 13 | 9.25 | 11 | 0 | 0 | 11 | NA | NA | 2 | 1 | 2 | NA | NA | NA | NA | NA | NA | NA | 1 | |
10.1002/adma.201103131 | SCI | Controlling the Dimensionality of Charge Transport in an Organic Electrochemical Transistor by Capacitive Coupling | Larsson, O; Laiho, A; Schmickler, W; Berggren, M; Crispin, X | http://onlinelibrary.wiley.com/resolve/doi?DOI=10.1002/adma.201103131 | http://www.altmetric.com/details.php?citation_id=419722 | 2011 | ADV MATER | ADVANCED MATERIALS | 6 | 0.25 | 32 | 0 | 0 | 32 | NA | NA | 1 | 1 | 1 | NA | NA | NA | NA | NA | NA | NA | NA | |
10.1002/adma.201200501 | SCI | Two-Dimensional Nanostructured Growth of Nanoclusters and Molecules on Insulating Surfaces | Barth, C; Gingras, M; Foster, AS; Gulans, A; Felix, G; Hynninen, T; Peresutti, R; Henry, CR | http://dx.doi.org/10.1002/adma.201200501 | http://www.altmetric.com/details.php?citation_id=743967 | 2012 | ADV MATER | ADVANCED MATERIALS | 1 | 15.592 | 17 | 0 | 0 | 17 | NA | 1 | 6 | 3 | 6 | 1 | NA | NA | NA | NA | NA | NA | 1 | |
10.1002/adma.201200931 | ELEC | Wire Metamaterials: Physics and Applications | Simovski, CR; Belov, PA; Atrashchenko, AV; Kivshar, YS | http://dx.doi.org/10.1002/adma.201200931 | http://www.altmetric.com/details.php?citation_id=1506819 | 2012 | ADV MATER | ADVANCED MATERIALS | 30 | 7 | 64 | 0 | 0 | 64 | NA | NA | 1 | NA | 1 | NA | NA | NA | NA | NA | NA | NA | 1 | |
10.1002/adma.201202549 | SCI | Self-Organized Origami Structures via Ion-Induced Plastic Strain | Chalapat, K; Chekurov, N; Jiang, H; Li, J; Parviz, B; Paraoanu, GS | http://dx.doi.org/10.1002/adma.201202549 | http://www.altmetric.com/details.php?citation_id=1008805 | 2013 | ADV MATER | ADVANCED MATERIALS | 2 | 21.25 | 43 | 0 | 0 | 43 | 1 | 2 | 9 | 2 | 9 | 1 | 1 | NA | 1 | NA | NA | NA | 1 | |
10.1002/adma.201202980 | SCI | Rebounding Droplet-Droplet Collisions on Superhydrophobic Surfaces: from the Phenomenon to Droplet Logic | Mertaniemi, H; Forchheimer, R; Ikkala, O; Ras, RHA | http://dx.doi.org/10.1002/adma.201202980 | http://www.altmetric.com/details.php?citation_id=934084 | 2012 | ADV MATER | ADVANCED MATERIALS | 10 | 60.042 | 27 | 0 | 0 | 27 | 3 | 1 | 36 | 20 | 32 | 3 | 2 | NA | 1 | NA | NA | NA | 2 | |
10.1002/adma.201204060 | SCI | Photoalignment and Surface-Relief-Grating Formation are Efficiently Combined in Low-Molecular-Weight Halogen-Bonded Complexes | Priimagi, A; Saccone, M; Cavallo, G; Shishido, A; Pilati, T; Metrangolo, P; Resnati, G | http://dx.doi.org/10.1002/adma.201204060 | http://www.altmetric.com/details.php?citation_id=1521259 | 2012 | ADV MATER | ADVANCED MATERIALS | 14 | 7 | 10 | 0 | 0 | 10 | NA | NA | 1 | NA | 1 | NA | NA | NA | NA | NA | NA | NA | 1 | |
10.1002/adma.201204696 | ELEC | Controlling Liquid Spreading Using Microfabricated Undercut Edges | Liimatainen, V; Sariola, V; Zhou, Q | http://dx.doi.org/10.1002/adma.201204696 | http://www.altmetric.com/details.php?citation_id=1300533 | 2013 | ADV MATER | ADVANCED MATERIALS | 2 | 10 | 22 | 0 | 0 | 22 | NA | NA | 3 | 1 | 2 | NA | NA | NA | NA | NA | NA | NA | 1 | |
10.1016/j.jbankfin.2013.01.042 | SCI | Drivers of holding period firm-level returns in private equity-backed buyouts | Valkama, P; Maula, M; Nikoskelainen, E; Wright, M | http://www.sciencedirect.com/science/article/pii/S0378426613000757 | http://www.altmetric.com/details.php?citation_id=1272796 | 2013 | J BANK FINANC | JOURNAL OF BANKING & FINANCE | 0 | 1 | 8 | 0 | 0 | 8 | NA | NA | 1 | 1 | 1 | NA | NA | NA | NA | NA | NA | NA | NA | |
10.1016/j.jbusres.2012.04.004 | BIZ | Creating novel consumer value vs. capturing value: Strategic emphases and financial performance implications | Aspara, J; Tikkanen, H | http://www.sciencedirect.com/science/article/pii/S0148296312001129 | http://www.altmetric.com/details.php?citation_id=1615643 | 2013 | J BUS RES | JOURNAL OF BUSINESS RESEARCH | 0 | 0.25 | 26 | 0 | 0 | 26 | NA | 1 | 1 | NA | 1 | NA | NA | NA | NA | NA | NA | NA | NA | |
10.1016/j.jbusvent.2012.12.001 | BIZ | Narrative attributions of entrepreneurial failure | Mantere, S; Aula, P; Schildt, H; Vaara, E | http://dx.doi.org/10.1016/j.jbusvent.2012.12.001 | http://www.altmetric.com/details.php?citation_id=1529611 | 2013 | J BUS VENTURING | JOURNAL OF BUSINESS VENTURING | 0 | 0.25 | 44 | 0 | 0 | 44 | NA | NA | 1 | 1 | 1 | NA | NA | NA | NA | NA | NA | NA | NA | |
10.1016/j.jcat.2013.08.027 | CHEM | The activity of ALD-prepared PtCo catalysts for ethanol oxidation in alkaline media | Santasalo-Aarnio, A; Sairanen, E; Aran-Ais, RM; Figueiredo, MC; Hua, J; Feliu, JM; Lehtonen, J; Karinen, R; Kallio, T | http://www.sciencedirect.com/science/article/pii/S0021951713003175 | http://www.altmetric.com/details.php?citation_id=1799013 | 2014 | J CATAL | JOURNAL OF CATALYSIS | 0 | 0.25 | 6 | 0 | 0 | 6 | NA | NA | 1 | 1 | 1 | NA | NA | NA | NA | NA | NA | NA | NA | |
10.1021/ct400813d | SCI | Critical Importance of van der Waals Stabilization in Strongly Chemically Bonded Surfaces: Cu(110):O | Bamidele, J; Brndiar, J; Gulans, A; Kantorovich, L; Stich, I | http://dx.doi.org/10.1021/ct400813d | http://www.altmetric.com/details.php?citation_id=1909772 | 2013 | J CHEM THEORY COMPUT | JOURNAL OF CHEMICAL THEORY AND COMPUTATION | 0 | 1 | 4 | 0 | 0 | 4 | NA | NA | 1 | 1 | 1 | NA | NA | NA | NA | NA | NA | NA | NA | |
10.1021/ct401016x | SCI | Pipek-Mezey Orbital Localization Using Various Partial Charge Estimates | Lehtola, S; Jonsson, H | http://pubs.acs.org/doi/abs/10.1021/ct401016x | http://www.altmetric.com/details.php?citation_id=2052366 | 2014 | J CHEM THEORY COMPUT | JOURNAL OF CHEMICAL THEORY AND COMPUTATION | 0 | 1 | 8 | 0 | 0 | 8 | NA | NA | 1 | 1 | 1 | NA | NA | NA | NA | NA | NA | NA | NA | |
10.1021/es300447t | ENG | Reductions in Particulate and NOx Emissions by Diesel Engine Parameter Adjustments with HVO Fuel | Happonen, M; Heikkila, J; Murtonen, T; Lehto, K; Sarjovaara, T; Larmi, M; Keskinen, J; Virtanen, A | http://dx.doi.org/10.1021/es300447t | http://www.altmetric.com/details.php?citation_id=1194445 | 2012 | ENVIRON SCI TECHNOL | ENVIRONMENTAL SCIENCE & TECHNOLOGY | 2 | 1 | 1 | 0 | 0 | 1 | NA | NA | 1 | 1 | 1 | NA | NA | NA | NA | NA | NA | NA | NA | |
10.1021/ic2021403 | CHEM | New Vanadium Selenites: Centrosymmetric Ca-2(VO2)(2)(SeO3)(3)(H2O)(2), Sr-2(VO2)(2)(SeO3)(3), and Ba(V2O5)(SeO3), and Noncentrosymmetric and Polar A(4)(VO2)(2)(SeO3)(4)(Se2O5) (A = Sr2+ or Pb2+) | Yeon, J; Kim, SH; Nguyen, SD; Lee, H; Halasyamani, PS | http://dx.doi.org/10.1021/ic2021403 | http://www.altmetric.com/details.php?citation_id=482028 | 2012 | INORG CHEM | INORGANIC CHEMISTRY | 8 | 1 | 6 | 0 | 0 | 6 | NA | NA | 1 | 1 | 1 | NA | NA | NA | NA | NA | NA | NA | NA |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
########################################################### | |
# | |
# Altmetrics data provided by Altmetric.com | |
# Web of Science data provided by Thomson Reuters | |
# | |
# 1. get data from local db | |
# 2. search Altmetric.com | |
# 3. merge | |
# | |
########################################################## | |
library(RPostgreSQL) | |
library(rAltmetric) | |
library(plyr) | |
library(reshape) | |
drv <- dbDriver("PostgreSQL") | |
con <- dbConnect(drv, user = "xxx", password = "xxxxx", dbname = "xxxx", host = "xxxx", port = xxxx) | |
# Fetch data by School to *.doi dataframes with 'dbGetQuery' SQL commands. Not shown here. | |
dbDisconnect(con) | |
dbUnloadDriver(drv) | |
# Merge DOIs (and other variables) by school | |
aalto.doi <- merge_all(list(arts.doi, biz.doi, chem.doi, elec.doi, eng.doi, sci.doi)) | |
# Preamble DOIs for the rAltmetric run | |
aalto.doi$di <- paste("doi/", aalto.doi$di, sep = "") | |
write.csv(aalto.doi, file = "aalto_metrics_2010.csv") | |
# Pull out just the DOIs | |
dois <- as.data.frame(aalto.doi$di, stringsAsFactors = FALSE) | |
# Rename the variable | |
names(dois) <- c("doi") | |
# Query Altmetric API with rAltmetric | |
raw_metrics <- llply(dois$doi, altmetrics, .progress = 'text') | |
metric_data <- ldply(raw_metrics, altmetric_data) | |
write.csv(metric_data, file = "aalto_metric_2010.csv") | |
# Merge with local data | |
aalto.doi$di <- sub("doi/", "", aalto.doi$di) | |
aalto.all.m <- merge(metric_data, aalto.doi, by.x = "doi", by.y = "di") | |
aalto.all <- aalto.all.m[ , c("doi", | |
"school", | |
"ti", | |
"au", | |
"url", | |
"details_url", | |
"py", | |
"j9", | |
"so", | |
"tc", | |
"score", | |
"mendeley", | |
"connotea", | |
"citeulike", | |
"readers_count", | |
"cited_by_gplus_count", | |
"cited_by_fbwalls_count", | |
"cited_by_posts_count", | |
"cited_by_tweeters_count", | |
"cited_by_accounts_count", | |
"cited_by_feeds_count", | |
"cited_by_videos_count", | |
"cited_by_delicious_count", | |
"cited_by_rdts_count", | |
"cited_by_forum_count", | |
"cited_by_qs_count", | |
"cited_by_rh_count", | |
"cited_by_msm_count")] | |
write.csv(aalto.all, file = "aalto_since2010.csv", row.names = FALSE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
library(ggplot2) | |
library(rCharts) | |
library(reshape2) | |
library(stringr) | |
library(ggvis) | |
# Few lines with double quotes inside fields terminated by quotes | |
# sed -i 's/""/%%/g' aalto_since2010.csv | |
aalto_all_m <- read.table(file = "aalto_since2010.csv", | |
header = TRUE, | |
sep = ",", | |
col.names = c("DOI", "School", "Title", "Authors", "URL", | |
"Altmetric.com_URL", "Year", "Journal_short", "Journal_long", | |
"WoS", "Altmetric", "Mendeley", "Connotea", "CiteULike", | |
"Readers_count", "GooglePlus", "Facebook", "Any_type_of_posts", "Twitter", | |
"Accounts", "Blog_posts", "Videos", "Delicious_bookmarks", | |
"Reddit", "Forums", | |
"StackExchange", "rh", | |
"Science_news_outlets"), | |
colClasses = c("character", "character", "character", "character", "character", | |
"character", "character", "character", "character", | |
"integer", "numeric", "integer", "integer", "integer", | |
"integer", "integer", "integer", "integer", "integer", | |
"integer", "integer", "integer", "integer", | |
"integer", "integer", | |
"integer", "integer", | |
"integer"), | |
stringsAsFactors = FALSE) | |
# Readers_count = Mendeley + CiteULike; rh = ? | |
aalto_all_m <- aalto_all_m[ ,c("DOI", "School", "Title", "Authors", "URL", | |
"Altmetric.com_URL", "Year", "Journal_short", "Journal_long", | |
"WoS", "Altmetric", "Mendeley", "Connotea", "CiteULike", | |
"GooglePlus", "Facebook", "Twitter", | |
"Accounts", "Blog_posts", "Videos", "Delicious_bookmarks", | |
"Reddit", "Forums", | |
"StackExchange", "rh", | |
"Science_news_outlets")] | |
names(aalto_all_m) <- c("DOI", "School", "Title", "Authors", "URL", | |
"AltmetricURL", "Year", "Journal short", "Journal", | |
"WoS", "Altmetric", "Mendeley", "Connotea", "CiteULike", | |
"GooglePlus", "Facebook", "Twitter", | |
"Accounts", "Blog posts", "Videos", "Delicious", | |
"Reddit", "Forums","StackExchange", "rh", "NewsOutlets") | |
# Altmetric.com_score value to ceiling | |
aalto_all_m$Altmetric <- as.integer(ceiling(aalto_all_m$Altmetric)) | |
# In original data, we have duplicate DOIs if the article is co-authored by | |
# multiple Schools. Here, we deliberately delete that information, and | |
# the DOI is randomnly put under one of the Schools | |
aalto_all <- aalto_all_m[!duplicated(aalto_all_m$DOI),] | |
# Some Altmetric.com data is NA, some 0 | |
aalto_all[is.na(aalto_all)] <- "" | |
# See remark on top | |
aalto_all$Title <- with(aalto_all, gsub("%%", "'", Title)) | |
# For unknown reason, some columns need to be transformed twice to integer | |
columns <- c(which(colnames(aalto_all) == "GooglePlus"):ncol(aalto_all)) | |
aalto_all[ ,columns] <- apply(aalto_all[ ,columns], 2, function(x) as.integer(as.character(x))) | |
# See ?toupper | |
simpleCap <- function(x) { | |
s <- strsplit(x, " ")[[1]] | |
paste(toupper(substring(s, 1,1)), substring(s, 2), | |
sep="", collapse=" ") | |
} | |
aalto_all$Journal <- sapply(aalto_all$Journal, tolower) | |
aalto_all$Journal <- sapply(aalto_all$Journal, function(x) simpleCap(x)) | |
# Acronyms for plot labels and tooltips | |
aalto_all$Title5 <- with(aalto_all, paste(substring(Title,1,5), " (", Year, ")", sep="")) | |
aalto_all$Title20 <- with(aalto_all, paste(substring(Title,1,20), " (", Year, ")", sep="")) | |
#aalto_all$Authors5 <- with(aalto_all, paste(substring(Authors,1,5), " (", Year, ")", sep="")) | |
aalto_all$Journal5 <- with(aalto_all, paste(substring(Journal,1,5), " (", Year, ")", sep="")) | |
# Number of authors | |
aalto_all$NrOfAuthors <- with(aalto_all, as.integer(str_count(Authors, ";")+1)) | |
# Keys for ggvis tooltips | |
aalto_all$keys <- seq_along(aalto_all[,1]) | |
metrics <- c("Altmetric", "WoS", "Mendeley", "Twitter", "Facebook", "GooglePlus", "CiteULike", | |
"Videos", "Reddit", "NewsOutlets", "NrOfAuthors") | |
dimensions <- c("Title", "Journal") | |
colsPlot <- c("Altmetric", "WoS", "Mendeley", "Twitter", "Facebook", "GooglePlus", "CiteULike", | |
"Videos", "Reddit", "NewsOutlets", "School", "Year", "Title5", "Journal5", "NrOfAuthors") | |
colsChart <- c("Altmetric", "WoS", "Mendeley", "Twitter", "Facebook", "GooglePlus", "CiteULike", | |
"Videos", "Reddit", "NewsOutlets", "id", "NrOfAuthors") | |
colsTable <- c("Journal", "Title", "AltmetricURL", "NrOfAuthors", "Altmetric", | |
"Authors", "Year", "WoS", "Mendeley", "School", | |
"Twitter", "Facebook", "GooglePlus", "CiteULike", | |
"Videos", "Reddit", "NewsOutlets") | |
schools <- "ARTS = School of Arts, Design and Architecture | |
<br/>BIZ = School of Business<br/>CHEM = School of Chemical Technology<br/>ELEC = School of Electrical Engineering<br/>ENG = School of Engineering | |
<br/>SCI = School of Science" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
shinyServer(function(input, output, session) { | |
output$text <- renderText({ | |
"Data as of 30th June 2014, by Altmetric and Thomson Reuters. <br/><br/> | |
For more details, see this <a href='https://blogs.aalto.fi/suoritin/2014/06/30/new-take-in-recent-altmetrics/' target='_blank'>blog posting</a>, and the | |
<a href='https://gist.github.com/tts/5df86b664b840c5927f9' target='_blank'>R code</a>" | |
}) | |
output$text2 <- renderText({ | |
"Altmetric = Altmetric score <br/> NrOfAuthors = Number of authors<br/>WoS = Thomson Reuters Web of Science citations <br/><br/> | |
For other metrics, see <a href='http://api.altmetric.com/docs/call_citations.html' target='_blank'>Altmetric API documentation</a>" | |
}) | |
output$ggplot2schools <- renderText({schools}) | |
output$nvd3schools <- renderText({schools}) | |
output$gvschools <- renderText({schools}) | |
# Render a selectize drop-down selection box | |
output$items <- renderUI({ | |
if ( input$dim == 'Title') { | |
nr <- 10 | |
} else { | |
nr <- 5 | |
} | |
selectizeInput( | |
inputId = 'items', | |
label = paste0('Select max ', nr, '. Click to delete'), | |
multiple = TRUE, | |
choices = aalto_all[ ,names(aalto_all) %in% input$dim], | |
options = list(maxItems = nr, placeholder = 'Start typing'), | |
width = '400px' | |
) | |
}) | |
# Render a selection box for choosing X coord | |
output$coordx <- renderUI({ | |
selectInput( | |
inputId = 'xc', | |
label = 'Metrics for X', | |
choices = as.list(metrics), | |
selected = c("WoS") | |
) | |
}) | |
# and the Y coord | |
output$coordy <- renderUI({ | |
selectInput( | |
inputId = 'yc', | |
label = 'Metrics for Y', | |
choices = as.list(metrics), | |
selected = c("Mendeley") | |
) | |
}) | |
items <- reactive({ | |
if(is.null(input$items)){ | |
return() | |
} | |
df <- aalto_all[aalto_all[[input$dim]] %in% input$items, ] | |
df | |
}) | |
# Output to Plot tab with ggplot2 | |
output$plot <- renderPlot({ | |
validate( | |
need(!is.null(items()), paste0("Please select some items from ", input$dim, ".")) | |
) | |
data <- items() | |
data <- data[, c(names(data) %in% colsPlot)] | |
nr <- nrow(data) | |
xval <- input$xc | |
yval <- input$yc | |
validate( | |
need(nrow(data[data[[xval]] == '',]) < nr, | |
paste0("No ", xval, " data. Please select another metrics for X")), | |
need(nrow(data[data[[yval]] == '',]) < nr, | |
paste0("No ", yval, " data. Please select another metrics for Y")) | |
) | |
p <- ggplot(data, aes_string(x = xval, y = yval)) + | |
geom_point(aes(colour = School), size = 3) + | |
theme_bw() + | |
geom_text(aes_string(label=paste0(input$dim,'5')), size=3, vjust=0, hjust=-0.1) | |
print(p) | |
}) | |
# Output to Chart tab with rCharts/NVD3 | |
output$chart <- renderChart({ | |
validate( | |
need(!is.null(items()), paste0("Please select some items from ", input$dim, ".")) | |
) | |
if(nrow(items()) == 0){ | |
return() | |
} | |
dataC <- items() | |
dataC$id <- substr(dataC$AltmetricURL, 47, nchar(dataC$AltmetricURL)) | |
dataCsub <- dataC[, c(names(dataC) %in% colsChart)] | |
# Transform data for plotting | |
dataM <- melt(dataCsub, id.vars="id") | |
nplot <- nPlot(value ~ id, data = dataM, group = "variable", type = "multiBarChart") | |
nplot$chart(reduceXTicks = FALSE) | |
nplot$xAxis(staggerLabels = TRUE) | |
nplot$set(dom="chart") | |
return(nplot) | |
}) | |
# http://stackoverflow.com/a/24557912/2613636 | |
selected <- reactive({ | |
if (is.null(input$items)) { | |
return(aalto_all) | |
} | |
df <- items() | |
#df <- aalto_all[aalto_all[[input$dim]] %in% input$items, ] | |
df$keys <-seq_along(df[,1]) | |
if(nrow(df) == 0){ | |
return(aalto_all) | |
} | |
df | |
}) | |
#prop(x = input_select(c("disp", "wt")), constant = FALSE) | |
selected %>% | |
ggvis(~WoS, ~NrOfAuthors, fill = ~School, key := ~keys) %>% | |
layer_points() %>% | |
add_tooltip(show_title) %>% | |
bind_shiny("gv") | |
show_title <- function(x=NULL) { | |
if(is.null(x)) return(NULL) | |
key <- x["keys"][[1]] | |
paste0(selected()$Title20[key], " ", selected()$Journal[key]) | |
} | |
# Output nr of items to Table tab | |
output$rownr <- renderText({ | |
paste("Number of items: ", if (is.null(items())) { "0" } else { nrow(items()) }) | |
}) | |
# Output to Table tab | |
output$table <- renderTable({ | |
if (is.null(items())) | |
return(invisible()) | |
rows <- items() | |
rows <- rows[, c(names(rows) %in% colsTable)] | |
# Shorten Authors and make URL of the Altmetric landing page | |
for (i in 1:nrow(rows)) { | |
au <- paste0(substr(rows$Authors[i], 1, 30), "...") | |
rows[i, c("Authors")] <- au | |
url <- substr(rows$AltmetricURL[i], 47, nchar(rows$AltmetricURL[i])) | |
doUrl <- paste("<a href=", rows[i, c("AltmetricURL")], "\" target=\"_blank\">", url, "</a>", sep = "") | |
rows[i, c("AltmetricURL")] <- doUrl | |
} | |
return(rows) | |
}, include.rownames = FALSE, sanitize.text.function = function(s) s) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
shinyUI(fluidPage( | |
titlePanel('Some (alt)metric data for Aalto University articles published since 2010'), | |
sidebarLayout( | |
sidebarPanel( | |
selectInput( | |
inputId = "dim", | |
label = "Dimension", | |
choices = c("Title", "Journal") | |
), | |
uiOutput("items"), | |
br(), | |
uiOutput("coordx"), | |
uiOutput("coordy"), | |
br(), | |
"Selection of X and Y affects only the first chart.", | |
br(), | |
br(), | |
htmlOutput("text") | |
), | |
mainPanel( | |
tabsetPanel( | |
tabPanel("Compare two metrics", plotOutput("plot"), | |
br(), | |
htmlOutput("ggplot2schools")), | |
tabPanel("All metrics", showOutput("chart", "nvd3"), | |
br(), | |
htmlOutput("text2")), | |
tabPanel("WoS and nr of authors", ggvisOutput("gv"), | |
br(), | |
paste0("With no selected items, shows all ", nrow(aalto_all), " publications"), | |
br(),br(), | |
htmlOutput("gvschools") | |
), | |
tabPanel("Data", | |
textOutput("rownr"), | |
br(), | |
tableOutput("table")) | |
) | |
) | |
) | |
)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment