New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a find_hits function? #21
Comments
Thank you! To your first question: More flexible arguments would be useful. I also think of the I also agree with your last point: When the function becomes too hard to implement and to maintain, we can write an extra vignette with examples like you did in your blog post. |
Is your preference a vignette or a function in this case? :-) |
Let's include your function in the package. Based on that we could present more complex queries in a vignette. Here's a first attempt based on your function: A simple query of "Aspirin", as well as two more detailed query of #' @param query_term Europe PMC search query: see <https://europepmc.org/Help>
#' for details
#' @param synonym logical, use MeSH terminology and the UniProt synonyms list, TRUE by default
#' @param period 1975:2016 by default
#'
find_hits <-
function(query_term,
synonym = TRUE,
period = 1975:2016) {
years <- period
results <-
purrr::map(years,
find_hits_by_year,
query_term = query_term,
synonym = synonym)
dplyr::bind_rows(results)
}
find_hits_by_year <- function(year, query_term, synonym) {
queryforall <-
paste0('(FIRST_PDATE:[', year, '-01-01+TO+', year, '-12-31])')
all_hits <-
as.numeric(europepmc::epmc_profile(queryforall, synonym)$pubType[1, 2])
queryforterm <-
paste0('(FIRST_PDATE:[',
year,
'-01-01+TO+',
year,
'-12-31]) AND ',
query_term)
term_hits <-
as.numeric(europepmc::epmc_profile(queryforterm, synonym)$pubType[1, 2])
return(tibble::tibble(
year = year,
all_hits = all_hits,
term_hits = term_hits
))
}
find_hits('aspirin', period = 2006:2016, synonym = FALSE)
#> # A tibble: 11 × 3
#> year all_hits term_hits
#> <int> <dbl> <dbl>
#> 1 2006 741228 2463
#> 2 2007 759017 2614
#> 3 2008 794495 3209
#> 4 2009 824702 3608
#> 5 2010 880624 4318
#> 6 2011 932154 4724
#> 7 2012 974162 5341
#> 8 2013 1032377 5974
#> 9 2014 1081101 6441
#> 10 2015 1139797 6685
#> 11 2016 1094684 5532
# link to cran packages in reference lists
find_hits('REF:"cran.r-project.org*"', period = 2006:2016, synonym = FALSE)
#> # A tibble: 11 × 3
#> year all_hits term_hits
#> <int> <dbl> <dbl>
#> 1 2006 741228 7
#> 2 2007 759017 18
#> 3 2008 794495 45
#> 4 2009 824702 83
#> 5 2010 880624 190
#> 6 2011 932154 300
#> 7 2012 974162 563
#> 8 2013 1032377 915
#> 9 2014 1081101 1423
#> 10 2015 1139797 2039
#> 11 2016 1094684 2206
# more complex with source Medline and publication type review
find_hits('(REF:"cran.r-project.org*") AND (SRC:"MED") AND (PUB_TYPE:"Review" OR PUB_TYPE:"review-article")', period = 2006:2016, synonym = FALSE)
#> # A tibble: 11 × 3
#> year all_hits term_hits
#> <int> <dbl> <dbl>
#> 1 2006 741228 1
#> 2 2007 759017 2
#> 3 2008 794495 1
#> 4 2009 824702 2
#> 5 2010 880624 11
#> 6 2011 932154 9
#> 7 2012 974162 25
#> 8 2013 1032377 25
#> 9 2014 1081101 39
#> 10 2015 1139797 36
#> 11 2016 1094684 24 |
Ok, do you want me to do a PR with this version? I'll add a test + remove the |
Yes, please send a PR with this version! |
(There is currently an issue with the resulttype |
I wasn't too sure how to name the function properly 🤔 |
Also absolutely no problem if you want to remove the ref to my own blog 😁 |
I both like the name and the link to your blog. Wonder if you want to add yourself as author, and if |
true I figured out |
Great! |
Added the modifications. I have a different Roxygen version so all .Rd were modified, they don't have an empty line as final line any more, sorry about that. |
adds function for finding hits trends cf #21
Was able to merge it without lots of pain, many thanks again. Will start a vignette about #evergreenreviewgraph this afternoon while on a train. Please feel free to contribute! |
Cool! And now that this package will have 2 vignettes, why not start using |
…e results, it is now data_frame() #21
Just had a look at the beginning of the vignette, looks promising, it will give super useful Insight! And by that I don't mean the link to my blog post! |
A few comments about the vignette (sorry I'm too lazy for a PR today):
But again really nice vignette, hence this issue to make it more visible! |
Wow, so helpful, many thanks! Will add it to the vignette and will try to start with blogdown! |
Awesome! I can help with blogdown if needed. Do you have admin rights to the repo of this package? You'll need that to change the source of Github pages to master/docs. |
Note: I can help with making the blogdown website but I can't give you admin access if you haven't got it yet, I don't have these rights. 😁 |
I don't find the "Settings" tab, so I guess not. |
yep! |
try it again |
Thanks, I got it! |
Cannot change to |
Yes I think you need to |
Oh no, got a |
Are you an Ubuntu user? I saw this error in ropensci/osmdata#64 I can build the website for you tomorrow on Windows 😎 but it'd be great to understand this Pandoc thing. Are you on the rOpenSci slack? |
No, a mac user, and unfortunately also not on the rOpenSci slack. Would be great if you could try to build the website tomorrow. |
I will! |
Maybe try the |
Wohoo 😃 using your trick did it! I pushed it, so it should be visible soon! |
well that's @mpadge's trick, thank him! 😉 |
and awesome! |
Once the website is up I'd recommend putting the link in the repo description :-) |
Will do! |
Forgot to close this issue, thanks again for this great functionality. |
As suggested in @njahn82's tweet and following my blog post
My questions regarding adding this function:
I think it might be useful to make it more flexible with arguments for type and source (both can't be used at the same time). What is your opinion?
In my use case I used it by year and the function was a wrapper to get all results for a given year range. However, is no. of hits / year a sufficient use case? Maybe the function should have a date range and a frequency or a sequence of dates as arguments? 🤔
and if it all becomes too complicated (to imagine all use cases / the main ones), should it rather be an example in a vignette?
The text was updated successfully, but these errors were encountered: