The What
The How
The methodology is fairly simple:
- Build the search query in Pubmed syntax based on user input parameters.
- Extract total number of articles from results.
- Output a visualization of the total counts for both selected institutions.
- Extract unique article identifiers from results.
- Output the number of article identifiers that match (i.e. “collaborations”) between the two selected institutions.
Build Query
GRUPO builds its queries based on two fields in particular: “Affiliation” and “Date.” Because this search term will have to be built multiple times (at least twice to compare results for two institutions) I wrote a helper function called build_query()
:
build_query = function(institution, startDate, endDate) {
if (grepl("-", institution)==TRUE) {
split_name = strsplit(institution, split="-")
search_term = paste(split_name[[1]][1], '[Affiliation]',
' AND ',
split_name[[1]][2],
'[Affiliation]',
' AND ',
startDate,
'[PDAT] : ',
endDate,
'[PDAT]',
sep='')
search_term = gsub("-","/",search_term)
} else {
search_term = paste(institution,
'[Affiliation]',
' AND ',
startDate,
'[PDAT] : ',
endDate,
'[PDAT]',
sep='')
search_term = gsub("-","/",search_term)
}
return(search_term)
}
The if/else logic in there accommodates cases like “University of North Carolina-Chapel Hill”, which otherwise wouldn’t search properly in the affiliation field. This method does depend on the institution name having its specific locale separated by a -
symbol. In other words, if you passed in “University of Colorado/Boulder” you’d be stuck.
So by using this function for the University of Virginia from January 1, 2014 to January 1, 2015 you’d get the following term:
University of Virginia[Affiliation] AND 2014/01/01[PDAT] : 2015/01/01[PDAT]
And for University of Texas-Austin over the same dates you get the following term:
University of Texas[Affiliation] AND Austin[Affiliation] AND 2014/01/01[PDAT] : 2015/01/01[PDAT]
The advantage of using this function in a Shiny app is that you can pass the institution names and dates dynamically. Users enter the input parameters for which date range and institutions to search via the widgets in the ui.R script.
For the app to work, there has to be one date picker widget and two text inputs …read more
Source:: r-bloggers.com