├── inst ├── vign │ ├── cache │ │ ├── alm3_2d77c6684ee8890ee6d61d451dce9410.rdb │ │ ├── almtitle_bb01a758f5afb305fe06be22d3c92b7c.rdb │ │ ├── almtotals_095df8646972a75208f37f5c64001fb1.rdb │ │ ├── byyear_ae7c32e27d9c03e5e24f53284fe2b666.rdb │ │ ├── easytocombine_0991ba66678bf6376f0ff135701bfdb4.rdb │ │ ├── plot_densityplot1_a4ca786d7e781a9769a3727398991f39.rdb │ │ ├── plot_densityplot2_345beb555bafdb2138cd81916337a187.rdb │ │ ├── plot_densityplot3_28d75c14e7c7d1931d1720367547264e.rdb │ │ ├── plot_densityplot4_dd9fae101bf17999062702105e3e1f0c.rdb │ │ ├── plot_densityplot5_67c4e4fba6137acaceb10823353143fd.rdb │ │ ├── xxx_63c180920b76a95ae5662f84eda699d8.rdb │ │ ├── xxx_63c180920b76a95ae5662f84eda699d8.rdx │ │ ├── alm3_2d77c6684ee8890ee6d61d451dce9410.rdx │ │ ├── xxx_63c180920b76a95ae5662f84eda699d8.RData │ │ ├── alm3_2d77c6684ee8890ee6d61d451dce9410.RData │ │ ├── almtitle_bb01a758f5afb305fe06be22d3c92b7c.rdx │ │ ├── byyear_ae7c32e27d9c03e5e24f53284fe2b666.RData │ │ ├── byyear_ae7c32e27d9c03e5e24f53284fe2b666.rdx │ │ ├── crossref_2b06a19ffb4fb5589fbe5bce812f160b.rdb │ │ ├── crossref_2b06a19ffb4fb5589fbe5bce812f160b.rdx │ │ ├── almevents_814eae916bf5cbc12f2758a4a1d8b196.rdb │ │ ├── almevents_814eae916bf5cbc12f2758a4a1d8b196.rdx │ │ ├── almtitle_bb01a758f5afb305fe06be22d3c92b7c.RData │ │ ├── almtotals_095df8646972a75208f37f5c64001fb1.rdx │ │ ├── crossref_2b06a19ffb4fb5589fbe5bce812f160b.RData │ │ ├── signposts1_c96f55a749822dd089b636087766def2.rdb │ │ ├── signposts1_c96f55a749822dd089b636087766def2.rdx │ │ ├── signposts2_0ea2fa222dc37a1b06b8296066fef3bd.rdb │ │ ├── signposts2_0ea2fa222dc37a1b06b8296066fef3bd.rdx │ │ ├── almevents_814eae916bf5cbc12f2758a4a1d8b196.RData │ │ ├── almtotals_095df8646972a75208f37f5c64001fb1.RData │ │ ├── easytocombine_0991ba66678bf6376f0ff135701bfdb4.rdx │ │ ├── signposts1_c96f55a749822dd089b636087766def2.RData │ │ ├── signposts2_0ea2fa222dc37a1b06b8296066fef3bd.RData │ │ ├── easytocombine_0991ba66678bf6376f0ff135701bfdb4.RData │ │ ├── plot_densityplot1_a4ca786d7e781a9769a3727398991f39.rdx │ │ ├── plot_densityplot2_345beb555bafdb2138cd81916337a187.rdx │ │ ├── plot_densityplot3_28d75c14e7c7d1931d1720367547264e.rdx │ │ ├── plot_densityplot4_dd9fae101bf17999062702105e3e1f0c.rdx │ │ ├── plot_densityplot5_67c4e4fba6137acaceb10823353143fd.rdx │ │ ├── plot_densityprep2_ca24074211f1c27ad066b59ab3b49e15.rdb │ │ ├── plot_densityprep2_ca24074211f1c27ad066b59ab3b49e15.rdx │ │ ├── plot_densityprep_2f789eae6f4874ab5f9bf83461897d72.RData │ │ ├── plot_densityprep_2f789eae6f4874ab5f9bf83461897d72.rdb │ │ ├── plot_densityprep_2f789eae6f4874ab5f9bf83461897d72.rdx │ │ ├── __packages │ │ ├── plot_densityplot1_a4ca786d7e781a9769a3727398991f39.RData │ │ ├── plot_densityplot2_345beb555bafdb2138cd81916337a187.RData │ │ ├── plot_densityplot3_28d75c14e7c7d1931d1720367547264e.RData │ │ ├── plot_densityplot4_dd9fae101bf17999062702105e3e1f0c.RData │ │ ├── plot_densityplot5_67c4e4fba6137acaceb10823353143fd.RData │ │ └── plot_densityprep2_ca24074211f1c27ad066b59ab3b49e15.RData │ ├── figure │ │ ├── signposts1.png │ │ ├── signposts2.png │ │ ├── totalmets.png │ │ ├── plot_densityplot1.png │ │ ├── plot_densityplot2.png │ │ ├── plot_densityplot3.png │ │ ├── plot_densityplot4.png │ │ ├── plot_densityplot5.png │ │ ├── unnamed-chunk-16-1.png │ │ ├── unnamed-chunk-17-1.png │ │ ├── unnamed-chunk-21-1.png │ │ ├── unnamed-chunk-22-1.png │ │ ├── unnamed-chunk-23-1.png │ │ ├── unnamed-chunk-24-1.png │ │ └── unnamed-chunk-25-1.png │ ├── alm_vignette.Rmd │ └── .Rhistory ├── assets │ └── img │ │ ├── altmetrics.png │ │ ├── unnamed-chunk-11.png │ │ ├── unnamed-chunk-12.png │ │ ├── unnamed-chunk-15.png │ │ ├── unnamed-chunk-16.png │ │ ├── unnamed-chunk-11-1.png │ │ ├── unnamed-chunk-12-1.png │ │ ├── unnamed-chunk-15-1.png │ │ └── unnamed-chunk-16-1.png └── ignore │ ├── plot_scatter.R │ └── plot_timeline.R ├── tests ├── test-all.R └── testthat │ ├── test-alm_datepub.R │ ├── test-alm_ids.R │ ├── test-alm_signposts.R │ ├── test-alm_title.R │ ├── test-alm_events.R │ └── test-plot_signposts.R ├── LICENSE ├── .gitignore ├── vignettes └── figure │ ├── signposts1.png │ ├── signposts2.png │ ├── totalmets.png │ ├── plot_densityplot1.png │ ├── plot_densityplot2.png │ ├── plot_densityplot3.png │ ├── plot_densityplot4.png │ ├── plot_densityplot5.png │ ├── unnamed-chunk-16-1.png │ ├── unnamed-chunk-17-1.png │ ├── unnamed-chunk-21-1.png │ ├── unnamed-chunk-22-1.png │ ├── unnamed-chunk-23-1.png │ ├── unnamed-chunk-24-1.png │ └── unnamed-chunk-25-1.png ├── cran-comments.md ├── R ├── globals.R ├── startup.R ├── alm_status.R ├── alm_requests.R ├── defunct.R ├── alm_plot.R ├── alm-package.R ├── alm_title.R ├── alm_datepub.R ├── plot_signposts.R ├── alm_signposts.R ├── alerts.R ├── alm_sources.R ├── zzz.R ├── plot_density.R ├── alm_ids.R └── alm_events.R ├── README.md ├── .Rbuildignore ├── man ├── alert_classes.Rd ├── almcompact.Rd ├── getkey.Rd ├── concat_todf.Rd ├── addmissing.Rd ├── alm_status.Rd ├── alm_requests.Rd ├── alm_capwords.Rd ├── alm_plot.Rd ├── alm-package.Rd ├── alm-defunct.Rd ├── alm_title.Rd ├── plot_signposts.Rd ├── alm_datepub.Rd ├── alm_alerts.Rd ├── alm_sources.Rd ├── alm_signposts.Rd ├── plot_density.Rd ├── alm_events.Rd └── alm_ids.Rd ├── alm.Rproj ├── Makefile ├── .travis.yml ├── README-NOT.md ├── NAMESPACE ├── appveyor.yml ├── DESCRIPTION ├── CONDUCT.md ├── man-roxygen ├── alm_params.R └── alm_egs.R └── NEWS /inst/vign/cache/alm3_2d77c6684ee8890ee6d61d451dce9410.rdb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/test-all.R: -------------------------------------------------------------------------------- 1 | library(testthat) 2 | test_check("alm") -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | YEAR: 2015 2 | COPYRIGHT HOLDER: Scott Chamberlain 3 | -------------------------------------------------------------------------------- /inst/vign/cache/almtitle_bb01a758f5afb305fe06be22d3c92b7c.rdb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /inst/vign/cache/almtotals_095df8646972a75208f37f5c64001fb1.rdb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /inst/vign/cache/byyear_ae7c32e27d9c03e5e24f53284fe2b666.rdb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .Rproj.user 3 | .Rhistory 4 | cache 5 | -------------------------------------------------------------------------------- /inst/vign/cache/easytocombine_0991ba66678bf6376f0ff135701bfdb4.rdb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /inst/vign/cache/plot_densityplot1_a4ca786d7e781a9769a3727398991f39.rdb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /inst/vign/cache/plot_densityplot2_345beb555bafdb2138cd81916337a187.rdb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /inst/vign/cache/plot_densityplot3_28d75c14e7c7d1931d1720367547264e.rdb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /inst/vign/cache/plot_densityplot4_dd9fae101bf17999062702105e3e1f0c.rdb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /inst/vign/cache/plot_densityplot5_67c4e4fba6137acaceb10823353143fd.rdb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /inst/assets/img/altmetrics.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/assets/img/altmetrics.png -------------------------------------------------------------------------------- /inst/vign/figure/signposts1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/figure/signposts1.png -------------------------------------------------------------------------------- /inst/vign/figure/signposts2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/figure/signposts2.png -------------------------------------------------------------------------------- /inst/vign/figure/totalmets.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/figure/totalmets.png -------------------------------------------------------------------------------- /vignettes/figure/signposts1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/vignettes/figure/signposts1.png -------------------------------------------------------------------------------- /vignettes/figure/signposts2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/vignettes/figure/signposts2.png -------------------------------------------------------------------------------- /vignettes/figure/totalmets.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/vignettes/figure/totalmets.png -------------------------------------------------------------------------------- /inst/assets/img/unnamed-chunk-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/assets/img/unnamed-chunk-11.png -------------------------------------------------------------------------------- /inst/assets/img/unnamed-chunk-12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/assets/img/unnamed-chunk-12.png -------------------------------------------------------------------------------- /inst/assets/img/unnamed-chunk-15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/assets/img/unnamed-chunk-15.png -------------------------------------------------------------------------------- /inst/assets/img/unnamed-chunk-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/assets/img/unnamed-chunk-16.png -------------------------------------------------------------------------------- /inst/assets/img/unnamed-chunk-11-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/assets/img/unnamed-chunk-11-1.png -------------------------------------------------------------------------------- /inst/assets/img/unnamed-chunk-12-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/assets/img/unnamed-chunk-12-1.png -------------------------------------------------------------------------------- /inst/assets/img/unnamed-chunk-15-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/assets/img/unnamed-chunk-15-1.png -------------------------------------------------------------------------------- /inst/assets/img/unnamed-chunk-16-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/assets/img/unnamed-chunk-16-1.png -------------------------------------------------------------------------------- /inst/vign/figure/plot_densityplot1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/figure/plot_densityplot1.png -------------------------------------------------------------------------------- /inst/vign/figure/plot_densityplot2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/figure/plot_densityplot2.png -------------------------------------------------------------------------------- /inst/vign/figure/plot_densityplot3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/figure/plot_densityplot3.png -------------------------------------------------------------------------------- /inst/vign/figure/plot_densityplot4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/figure/plot_densityplot4.png -------------------------------------------------------------------------------- /inst/vign/figure/plot_densityplot5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/figure/plot_densityplot5.png -------------------------------------------------------------------------------- /vignettes/figure/plot_densityplot1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/vignettes/figure/plot_densityplot1.png -------------------------------------------------------------------------------- /vignettes/figure/plot_densityplot2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/vignettes/figure/plot_densityplot2.png -------------------------------------------------------------------------------- /vignettes/figure/plot_densityplot3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/vignettes/figure/plot_densityplot3.png -------------------------------------------------------------------------------- /vignettes/figure/plot_densityplot4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/vignettes/figure/plot_densityplot4.png -------------------------------------------------------------------------------- /vignettes/figure/plot_densityplot5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/vignettes/figure/plot_densityplot5.png -------------------------------------------------------------------------------- /inst/vign/figure/unnamed-chunk-16-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/figure/unnamed-chunk-16-1.png -------------------------------------------------------------------------------- /inst/vign/figure/unnamed-chunk-17-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/figure/unnamed-chunk-17-1.png -------------------------------------------------------------------------------- /inst/vign/figure/unnamed-chunk-21-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/figure/unnamed-chunk-21-1.png -------------------------------------------------------------------------------- /inst/vign/figure/unnamed-chunk-22-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/figure/unnamed-chunk-22-1.png -------------------------------------------------------------------------------- /inst/vign/figure/unnamed-chunk-23-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/figure/unnamed-chunk-23-1.png -------------------------------------------------------------------------------- /inst/vign/figure/unnamed-chunk-24-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/figure/unnamed-chunk-24-1.png -------------------------------------------------------------------------------- /inst/vign/figure/unnamed-chunk-25-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/figure/unnamed-chunk-25-1.png -------------------------------------------------------------------------------- /vignettes/figure/unnamed-chunk-16-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/vignettes/figure/unnamed-chunk-16-1.png -------------------------------------------------------------------------------- /vignettes/figure/unnamed-chunk-17-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/vignettes/figure/unnamed-chunk-17-1.png -------------------------------------------------------------------------------- /vignettes/figure/unnamed-chunk-21-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/vignettes/figure/unnamed-chunk-21-1.png -------------------------------------------------------------------------------- /vignettes/figure/unnamed-chunk-22-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/vignettes/figure/unnamed-chunk-22-1.png -------------------------------------------------------------------------------- /vignettes/figure/unnamed-chunk-23-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/vignettes/figure/unnamed-chunk-23-1.png -------------------------------------------------------------------------------- /vignettes/figure/unnamed-chunk-24-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/vignettes/figure/unnamed-chunk-24-1.png -------------------------------------------------------------------------------- /vignettes/figure/unnamed-chunk-25-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/vignettes/figure/unnamed-chunk-25-1.png -------------------------------------------------------------------------------- /inst/vign/cache/xxx_63c180920b76a95ae5662f84eda699d8.rdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/cache/xxx_63c180920b76a95ae5662f84eda699d8.rdb -------------------------------------------------------------------------------- /inst/vign/cache/xxx_63c180920b76a95ae5662f84eda699d8.rdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/cache/xxx_63c180920b76a95ae5662f84eda699d8.rdx -------------------------------------------------------------------------------- /inst/vign/cache/alm3_2d77c6684ee8890ee6d61d451dce9410.rdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/cache/alm3_2d77c6684ee8890ee6d61d451dce9410.rdx -------------------------------------------------------------------------------- /inst/vign/cache/xxx_63c180920b76a95ae5662f84eda699d8.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/cache/xxx_63c180920b76a95ae5662f84eda699d8.RData -------------------------------------------------------------------------------- /inst/vign/cache/alm3_2d77c6684ee8890ee6d61d451dce9410.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/cache/alm3_2d77c6684ee8890ee6d61d451dce9410.RData -------------------------------------------------------------------------------- /inst/vign/cache/almtitle_bb01a758f5afb305fe06be22d3c92b7c.rdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/cache/almtitle_bb01a758f5afb305fe06be22d3c92b7c.rdx -------------------------------------------------------------------------------- /inst/vign/cache/byyear_ae7c32e27d9c03e5e24f53284fe2b666.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/cache/byyear_ae7c32e27d9c03e5e24f53284fe2b666.RData -------------------------------------------------------------------------------- /inst/vign/cache/byyear_ae7c32e27d9c03e5e24f53284fe2b666.rdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/cache/byyear_ae7c32e27d9c03e5e24f53284fe2b666.rdx -------------------------------------------------------------------------------- /inst/vign/cache/crossref_2b06a19ffb4fb5589fbe5bce812f160b.rdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/cache/crossref_2b06a19ffb4fb5589fbe5bce812f160b.rdb -------------------------------------------------------------------------------- /inst/vign/cache/crossref_2b06a19ffb4fb5589fbe5bce812f160b.rdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/cache/crossref_2b06a19ffb4fb5589fbe5bce812f160b.rdx -------------------------------------------------------------------------------- /cran-comments.md: -------------------------------------------------------------------------------- 1 | R CMD CHECK passed on my local OS X with R 3.1.3 and R development version, Ubuntu running 2 | on Travis-CI, and Win builder. 3 | 4 | Thanks! Scott Chamberlain 5 | -------------------------------------------------------------------------------- /inst/vign/cache/almevents_814eae916bf5cbc12f2758a4a1d8b196.rdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/cache/almevents_814eae916bf5cbc12f2758a4a1d8b196.rdb -------------------------------------------------------------------------------- /inst/vign/cache/almevents_814eae916bf5cbc12f2758a4a1d8b196.rdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/cache/almevents_814eae916bf5cbc12f2758a4a1d8b196.rdx -------------------------------------------------------------------------------- /inst/vign/cache/almtitle_bb01a758f5afb305fe06be22d3c92b7c.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/cache/almtitle_bb01a758f5afb305fe06be22d3c92b7c.RData -------------------------------------------------------------------------------- /inst/vign/cache/almtotals_095df8646972a75208f37f5c64001fb1.rdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/cache/almtotals_095df8646972a75208f37f5c64001fb1.rdx -------------------------------------------------------------------------------- /inst/vign/cache/crossref_2b06a19ffb4fb5589fbe5bce812f160b.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/cache/crossref_2b06a19ffb4fb5589fbe5bce812f160b.RData -------------------------------------------------------------------------------- /inst/vign/cache/signposts1_c96f55a749822dd089b636087766def2.rdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/cache/signposts1_c96f55a749822dd089b636087766def2.rdb -------------------------------------------------------------------------------- /inst/vign/cache/signposts1_c96f55a749822dd089b636087766def2.rdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/cache/signposts1_c96f55a749822dd089b636087766def2.rdx -------------------------------------------------------------------------------- /inst/vign/cache/signposts2_0ea2fa222dc37a1b06b8296066fef3bd.rdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/cache/signposts2_0ea2fa222dc37a1b06b8296066fef3bd.rdb -------------------------------------------------------------------------------- /inst/vign/cache/signposts2_0ea2fa222dc37a1b06b8296066fef3bd.rdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/cache/signposts2_0ea2fa222dc37a1b06b8296066fef3bd.rdx -------------------------------------------------------------------------------- /R/globals.R: -------------------------------------------------------------------------------- 1 | if (base::getRversion() >= "2.15.1") { 2 | utils::globalVariables(c("value", "variable","doi","id","nPlot")) ## Neded in functions plot_density and plot_signposts 3 | } 4 | -------------------------------------------------------------------------------- /inst/vign/cache/almevents_814eae916bf5cbc12f2758a4a1d8b196.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/cache/almevents_814eae916bf5cbc12f2758a4a1d8b196.RData -------------------------------------------------------------------------------- /inst/vign/cache/almtotals_095df8646972a75208f37f5c64001fb1.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/cache/almtotals_095df8646972a75208f37f5c64001fb1.RData -------------------------------------------------------------------------------- /inst/vign/cache/easytocombine_0991ba66678bf6376f0ff135701bfdb4.rdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/cache/easytocombine_0991ba66678bf6376f0ff135701bfdb4.rdx -------------------------------------------------------------------------------- /inst/vign/cache/signposts1_c96f55a749822dd089b636087766def2.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/cache/signposts1_c96f55a749822dd089b636087766def2.RData -------------------------------------------------------------------------------- /inst/vign/cache/signposts2_0ea2fa222dc37a1b06b8296066fef3bd.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/cache/signposts2_0ea2fa222dc37a1b06b8296066fef3bd.RData -------------------------------------------------------------------------------- /inst/vign/cache/easytocombine_0991ba66678bf6376f0ff135701bfdb4.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/cache/easytocombine_0991ba66678bf6376f0ff135701bfdb4.RData -------------------------------------------------------------------------------- /inst/vign/cache/plot_densityplot1_a4ca786d7e781a9769a3727398991f39.rdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/cache/plot_densityplot1_a4ca786d7e781a9769a3727398991f39.rdx -------------------------------------------------------------------------------- /inst/vign/cache/plot_densityplot2_345beb555bafdb2138cd81916337a187.rdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/cache/plot_densityplot2_345beb555bafdb2138cd81916337a187.rdx -------------------------------------------------------------------------------- /inst/vign/cache/plot_densityplot3_28d75c14e7c7d1931d1720367547264e.rdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/cache/plot_densityplot3_28d75c14e7c7d1931d1720367547264e.rdx -------------------------------------------------------------------------------- /inst/vign/cache/plot_densityplot4_dd9fae101bf17999062702105e3e1f0c.rdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/cache/plot_densityplot4_dd9fae101bf17999062702105e3e1f0c.rdx -------------------------------------------------------------------------------- /inst/vign/cache/plot_densityplot5_67c4e4fba6137acaceb10823353143fd.rdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/cache/plot_densityplot5_67c4e4fba6137acaceb10823353143fd.rdx -------------------------------------------------------------------------------- /inst/vign/cache/plot_densityprep2_ca24074211f1c27ad066b59ab3b49e15.rdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/cache/plot_densityprep2_ca24074211f1c27ad066b59ab3b49e15.rdb -------------------------------------------------------------------------------- /inst/vign/cache/plot_densityprep2_ca24074211f1c27ad066b59ab3b49e15.rdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/cache/plot_densityprep2_ca24074211f1c27ad066b59ab3b49e15.rdx -------------------------------------------------------------------------------- /inst/vign/cache/plot_densityprep_2f789eae6f4874ab5f9bf83461897d72.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/cache/plot_densityprep_2f789eae6f4874ab5f9bf83461897d72.RData -------------------------------------------------------------------------------- /inst/vign/cache/plot_densityprep_2f789eae6f4874ab5f9bf83461897d72.rdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/cache/plot_densityprep_2f789eae6f4874ab5f9bf83461897d72.rdb -------------------------------------------------------------------------------- /inst/vign/cache/plot_densityprep_2f789eae6f4874ab5f9bf83461897d72.rdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/cache/plot_densityprep_2f789eae6f4874ab5f9bf83461897d72.rdx -------------------------------------------------------------------------------- /inst/vign/cache/__packages: -------------------------------------------------------------------------------- 1 | alm 2 | base 3 | devtools 4 | ggplot2 5 | knitr 6 | plyr 7 | Rdocumentation 8 | roxygen2 9 | rplos 10 | sacbox 11 | slidify 12 | slidifyLibraries 13 | testthat 14 | -------------------------------------------------------------------------------- /inst/vign/cache/plot_densityplot1_a4ca786d7e781a9769a3727398991f39.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/cache/plot_densityplot1_a4ca786d7e781a9769a3727398991f39.RData -------------------------------------------------------------------------------- /inst/vign/cache/plot_densityplot2_345beb555bafdb2138cd81916337a187.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/cache/plot_densityplot2_345beb555bafdb2138cd81916337a187.RData -------------------------------------------------------------------------------- /inst/vign/cache/plot_densityplot3_28d75c14e7c7d1931d1720367547264e.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/cache/plot_densityplot3_28d75c14e7c7d1931d1720367547264e.RData -------------------------------------------------------------------------------- /inst/vign/cache/plot_densityplot4_dd9fae101bf17999062702105e3e1f0c.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/cache/plot_densityplot4_dd9fae101bf17999062702105e3e1f0c.RData -------------------------------------------------------------------------------- /inst/vign/cache/plot_densityplot5_67c4e4fba6137acaceb10823353143fd.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/cache/plot_densityplot5_67c4e4fba6137acaceb10823353143fd.RData -------------------------------------------------------------------------------- /inst/vign/cache/plot_densityprep2_ca24074211f1c27ad066b59ab3b49e15.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/alm/HEAD/inst/vign/cache/plot_densityprep2_ca24074211f1c27ad066b59ab3b49e15.RData -------------------------------------------------------------------------------- /R/startup.R: -------------------------------------------------------------------------------- 1 | .onAttach <- function(...) { 2 | packageStartupMessage("\n\n New to alm? Tutorial at http://ropensci.org/tutorials/alm_tutorial.html. Use suppressPackageStartupMessages() to suppress these startup messages in the future\n") 3 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # alm 2 | 3 | [![Project Status: Abandoned](https://www.repostatus.org/badges/latest/abandoned.svg)](https://www.repostatus.org/#abandoned) 4 | 5 | This repository has been archived. The former README is now in [README-NOT.md](README-NOT.md). 6 | -------------------------------------------------------------------------------- /.Rbuildignore: -------------------------------------------------------------------------------- 1 | .gitignore 2 | .travis.yml 3 | Makefile 4 | man-roxygen 5 | inst/ignore 6 | inst/assets 7 | inst/stuff 8 | vignettes/margins.sty 9 | .Rhistory 10 | ^appveyor\.yml$ 11 | README.Rmd 12 | ^.*\.Rproj$ 13 | ^\.Rproj\.user$ 14 | cache 15 | cran-comments.md 16 | ^CONDUCT.md$ 17 | -------------------------------------------------------------------------------- /man/alert_classes.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.1.0): do not edit by hand 2 | % Please edit documentation in R/zzz.R 3 | \name{alert_classes} 4 | \alias{alert_classes} 5 | \title{List the possible alert classes} 6 | \usage{ 7 | alert_classes() 8 | } 9 | \description{ 10 | List the possible alert classes 11 | } 12 | 13 | -------------------------------------------------------------------------------- /man/almcompact.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.1.0): do not edit by hand 2 | % Please edit documentation in R/zzz.R 3 | \name{almcompact} 4 | \alias{almcompact} 5 | \title{Remove null elements in a list} 6 | \usage{ 7 | almcompact(x) 8 | } 9 | \arguments{ 10 | \item{x}{A list} 11 | } 12 | \description{ 13 | Remove null elements in a list 14 | } 15 | \keyword{internal} 16 | 17 | -------------------------------------------------------------------------------- /alm.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: knitr 13 | LaTeX: pdfLaTeX 14 | 15 | AutoAppendNewline: Yes 16 | 17 | BuildType: Package 18 | PackageUseDevtools: Yes 19 | PackageInstallArgs: --no-multiarch --with-keep.source 20 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | all: move rmd2md 2 | 3 | move: 4 | cp inst/vign/alm_vignette.md vignettes/ 5 | cp -rf inst/vign/figure/* vignettes/figure/ 6 | 7 | pandoc: 8 | cd vignettes;\ 9 | pandoc -H margins.sty alm_vignette.md -o alm_vignette.pdf --highlight-style=tango;\ 10 | pandoc -H margins.sty alm_vignette.md -o alm_vignette.html --highlight-style=tango 11 | 12 | rmd2md: 13 | cd vignettes;\ 14 | mv alm_vignette.md alm_vignette.Rmd 15 | 16 | reducepdf: 17 | Rscript -e 'tools::compactPDF("vignettes/alm_vignette.pdf", gs_quality = "ebook")' 18 | -------------------------------------------------------------------------------- /man/getkey.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.1.0): do not edit by hand 2 | % Please edit documentation in R/zzz.R 3 | \name{getkey} 4 | \alias{getkey} 5 | \title{Function to get an API key.} 6 | \usage{ 7 | getkey(x = NULL) 8 | } 9 | \arguments{ 10 | \item{x}{An API key, defaults to NULL.} 11 | } 12 | \description{ 13 | Checks first to get key from your .Rprofile file for an API key with the name 14 | 'PlosApiKey'. If it is not found, the default guest key is used. 15 | } 16 | \examples{ 17 | \dontrun{ 18 | getkey() 19 | } 20 | } 21 | \keyword{internal} 22 | 23 | -------------------------------------------------------------------------------- /tests/testthat/test-alm_datepub.R: -------------------------------------------------------------------------------- 1 | # tests for alm_datepub fxn in alm 2 | context("alm_datepub") 3 | 4 | test_that("alm_datepub returns the correct value", { 5 | expect_that(alm_datepub('10.1371/journal.pone.0026871'), matches("2012-03-26")) 6 | expect_that(alm_datepub('10.1371/journal.pone.0026871', get = 'year'), equals(2012)) 7 | }) 8 | 9 | test_that("alm_datepub returns the correct class", { 10 | expect_that(alm_datepub('10.1371/journal.pone.0026871'), is_a("character")) 11 | expect_that(alm_datepub('10.1371/journal.pone.0026871', get='year'), is_a("numeric")) 12 | }) 13 | -------------------------------------------------------------------------------- /man/concat_todf.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.1.0): do not edit by hand 2 | % Please edit documentation in R/zzz.R 3 | \name{concat_todf} 4 | \alias{concat_todf} 5 | \title{Concatenate author names, if present, used in other functions.} 6 | \usage{ 7 | concat_todf(x) 8 | } 9 | \arguments{ 10 | \item{x}{a single list element with PLoS API returned nested elements} 11 | } 12 | \value{ 13 | data.frame of results, with authors concatenated to single vector. 14 | } 15 | \description{ 16 | Concatenate author names, if present, used in other functions. 17 | } 18 | \keyword{internal} 19 | 20 | -------------------------------------------------------------------------------- /man/addmissing.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.1.0): do not edit by hand 2 | % Please edit documentation in R/zzz.R 3 | \name{addmissing} 4 | \alias{addmissing} 5 | \title{Adds elements in a list that are missing because they were not returned 6 | in the PLoS API call.} 7 | \usage{ 8 | addmissing(x) 9 | } 10 | \arguments{ 11 | \item{x}{A list with PLoS API returned nested elements} 12 | } 13 | \value{ 14 | A list with the missing element added with an 15 | "na", if it is missing. 16 | } 17 | \description{ 18 | Adds elements in a list that are missing because they were not returned 19 | in the PLoS API call. 20 | } 21 | \keyword{internal} 22 | 23 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: r 2 | 3 | r_github_packages: 4 | - jimhester/robustr 5 | - jimhester/covr 6 | 7 | after_success: 8 | - Rscript -e 'library(covr); coveralls()' 9 | 10 | notifications: 11 | email: 12 | on_success: change 13 | on_failure: change 14 | slack: 15 | secure: lnO7OWkimtwP3AZImeDuoo8WH39ZNXDX5mCNsVonSZlXgHCTuf4mXK+6RAA1x6EJFmypG3qbWD+6YQuUcLMji4oSN4p3sVSC2Z2Rdz0Ef+4UspFij8oKcYainI2qwG89FYn0CC8ITrh+kxtLbTLF6VYwb5jlZ8DRsAk8LVWxm+g= 16 | 17 | env: 18 | global: 19 | secure: hjxfr7bGSDYgCHZdEkdtIWRXTe3Fkj8hTFBNLqqOPJku1YOKEIhDzKMW/pEjnHBaquv7OHlZKDlC3dMGtLWkpxJX9wW6cSC3n+H57BkQu32fTe9MuvJZCbGaXUIAn1/hHBGx5Ux+r8SP3baOLw4JzNrMCrXQEVXmyzWQ/c6EJSI= 20 | -------------------------------------------------------------------------------- /R/alm_status.R: -------------------------------------------------------------------------------- 1 | #' Check status of an ALM service. 2 | #' 3 | #' @export 4 | #' @param key (character) Your API key, either enter, or loads from .Rprofile. Only required for 5 | #' PKP source, not the others. 6 | #' @param url API endpoint, defaults to http://alm.plos.org/api/v5/status (character) 7 | #' @param ... optional additional curl options (debugging tools mostly) 8 | #' @examples \dontrun{ 9 | #' alm_status() 10 | #' } 11 | 12 | alm_status <- function(key = NULL, url = 'http://alm.plos.org/api/v5/status', ...) 13 | { 14 | out <- GET(url, query=almcompact(list(api_key = key)), ...) 15 | stop_for_status(out) 16 | tt <- content(out, as = "text") 17 | jsonlite::fromJSON(tt, TRUE)$data 18 | } 19 | -------------------------------------------------------------------------------- /man/alm_status.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.1.0): do not edit by hand 2 | % Please edit documentation in R/alm_status.R 3 | \name{alm_status} 4 | \alias{alm_status} 5 | \title{Check status of an ALM service.} 6 | \usage{ 7 | alm_status(key = NULL, url = "http://alm.plos.org/api/v5/status", ...) 8 | } 9 | \arguments{ 10 | \item{key}{(character) Your API key, either enter, or loads from .Rprofile. Only required for 11 | PKP source, not the others.} 12 | 13 | \item{url}{API endpoint, defaults to http://alm.plos.org/api/v5/status (character)} 14 | 15 | \item{...}{optional additional curl options (debugging tools mostly)} 16 | } 17 | \description{ 18 | Check status of an ALM service. 19 | } 20 | \examples{ 21 | \dontrun{ 22 | alm_status() 23 | } 24 | } 25 | 26 | -------------------------------------------------------------------------------- /tests/testthat/test-alm_ids.R: -------------------------------------------------------------------------------- 1 | # tests for alm fxn in alm 2 | context("alm") 3 | 4 | dat <- alm_ids(doi="10.1371/journal.pone.0029797") 5 | dat2 <- alm_ids(doi='10.1371/journal.pone.0029797', info='detail') 6 | dat3 <- alm_ids(doi='10.1371/journal.pone.0035869', total_details=TRUE) 7 | dat4 <- alm_ids(doi='10.1371/journal.pone.0036240', sum_metrics='day') 8 | 9 | test_that("alm returns the correct class", { 10 | expect_that(dat, is_a("list")) 11 | expect_that(dat$meta, is_a("data.frame")) 12 | expect_that(dat$data, is_a("data.frame")) 13 | expect_that(dat2, is_a("list")) 14 | expect_that(dat2$data$signposts, is_a("data.frame")) 15 | expect_that(dat3, is_a("list")) 16 | expect_that(dat3$data, is_a("data.frame")) 17 | expect_that(dat4, is_a("list")) 18 | }) 19 | -------------------------------------------------------------------------------- /man/alm_requests.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.1.0): do not edit by hand 2 | % Please edit documentation in R/alm_requests.R 3 | \name{alm_requests} 4 | \alias{alm_requests} 5 | \title{Retrieve API requests data} 6 | \usage{ 7 | alm_requests(key, url = "http://alm.plos.org/api/v5/api_requests", ...) 8 | } 9 | \arguments{ 10 | \item{key}{API key. Required.} 11 | 12 | \item{url}{URL for the api requests endpoint. Required.} 13 | 14 | \item{...}{Curl args to \code{\link[httr]{GET}}} 15 | } 16 | \description{ 17 | Retrieve API requests data 18 | } 19 | \details{ 20 | This function requires authentication via an API key. 21 | } 22 | \examples{ 23 | \dontrun{ 24 | out <- alm_requests() 25 | out$meta 26 | dat <- out$data 27 | head( dat ) 28 | dat[ dat$db_duration > 100, ] 29 | } 30 | } 31 | 32 | -------------------------------------------------------------------------------- /tests/testthat/test-alm_signposts.R: -------------------------------------------------------------------------------- 1 | # tests for alm_signposts fxn in alm 2 | context("alm_signposts") 3 | 4 | dat1 <- alm_signposts(doi="10.1371/journal.pone.0029797") 5 | dois <- c('10.1371/journal.pone.0001543','10.1371/journal.pone.0040117', 6 | '10.1371/journal.pone.0029797','10.1371/journal.pone.0039395') 7 | dat2 <- alm_signposts(doi=dois) 8 | 9 | test_that("alm_signposts returns the correct class", { 10 | expect_that(dat1, is_a("data.frame")) 11 | expect_that(dat2, is_a("data.frame")) 12 | expect_that(dat1$viewed, is_a("integer")) 13 | expect_that(dat2$cited, is_a("integer")) 14 | expect_that(dat2$id, is_a("character")) 15 | }) 16 | 17 | test_that("alm_signposts returns the correct dimensions", { 18 | expect_that(nrow(dat1), equals(1)) 19 | expect_that(nrow(dat2), equals(4)) 20 | }) 21 | -------------------------------------------------------------------------------- /man/alm_capwords.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.1.0): do not edit by hand 2 | % Please edit documentation in R/zzz.R 3 | \name{alm_capwords} 4 | \alias{alm_capwords} 5 | \title{Capitalize the first letter of a character string.} 6 | \usage{ 7 | alm_capwords(s, strict = FALSE, onlyfirst = FALSE) 8 | } 9 | \arguments{ 10 | \item{s}{A character string} 11 | 12 | \item{strict}{Should the algorithm be strict about capitalizing. Defaults to FALSE.} 13 | 14 | \item{onlyfirst}{Capitalize only first word, lowercase all others. Useful for 15 | taxonomic names.} 16 | } 17 | \description{ 18 | Capitalize the first letter of a character string. 19 | } 20 | \examples{ 21 | alm_capwords(c("using AIC for model selection")) 22 | alm_capwords(c("using AIC for model selection"), strict=TRUE) 23 | } 24 | \keyword{internal} 25 | 26 | -------------------------------------------------------------------------------- /tests/testthat/test-alm_title.R: -------------------------------------------------------------------------------- 1 | # tests for alm_title fxn in alm 2 | context("alm_title") 3 | 4 | test_that("almtitle returns the correct value", { 5 | expect_match(suppressWarnings(alm_title(doi='10.1371/journal.pbio.0000012')), "Genome-Wide RNAi of") 6 | expect_match(suppressWarnings(alm_title(doi='10.1371/journal.pbio.1001357')), "Niche-Associated Activation") 7 | }) 8 | 9 | test_that("alm_title returns the correct class", { 10 | expect_is(suppressWarnings(alm_title(doi='10.1371/journal.pbio.0000012')), "character") 11 | expect_is(suppressWarnings(alm_title(doi='10.1371/journal.pbio.1001357')), "character") 12 | }) 13 | 14 | test_that("alm_title returns a title of the correct class", { 15 | expect_is(suppressWarnings(alm_title(doi='10.1371/journal.pbio.1001357')), "character") 16 | expect_is(suppressWarnings(alm_title(doi='10.1371/journal.pbio.0000012')), "character") 17 | }) 18 | -------------------------------------------------------------------------------- /tests/testthat/test-alm_events.R: -------------------------------------------------------------------------------- 1 | # tests for almevents fxn in alm 2 | context("almevents") 3 | 4 | out <- alm_events(doi="10.1371/journal.pone.0029797") 5 | out <- out[!out %in% c("sorry, no events content yet","parser not written yet")] # remove those with no data 6 | 7 | test_that("almevents returns the correct class", { 8 | expect_that(out, is_a("list")) 9 | }) 10 | 11 | test_that("almevents returns correct things when two dois passed in", { 12 | dois <- c('10.1371/journal.pone.0001543','10.1371/journal.pone.0040117') 13 | out2 <- alm_events(doi=dois) 14 | expect_is(out2, "list") 15 | expect_equal(length(out2), 2) 16 | expect_equal(length(out2), 2) 17 | }) 18 | 19 | test_that("almevents returns correctly when one specific source requested", { 20 | out3 <- alm_events(source_id="crossref") 21 | expect_equal(length(out3), 50) 22 | expect_match(names(out3[[1]]), "crossref") 23 | }) 24 | -------------------------------------------------------------------------------- /man/alm_plot.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.1.0): do not edit by hand 2 | % Please edit documentation in R/alm_plot.R 3 | \name{alm_plot} 4 | \alias{alm_plot} 5 | \title{Plot results of a call to the alm function.} 6 | \usage{ 7 | alm_plot(dat) 8 | } 9 | \arguments{ 10 | \item{dat}{Output from \code{alm_ids} (character)} 11 | } 12 | \value{ 13 | A ggplot2 bar plot for `totalmetrics` or line plot for `history`. 14 | } 15 | \description{ 16 | Plot results of a call to the alm function. 17 | } 18 | \examples{ 19 | \dontrun{ 20 | out <- alm_ids(doi='10.1371/journal.pone.0001543', info='detail') 21 | alm_plot(out) 22 | # works from info=totals too 23 | out <- alm_ids(doi='10.1371/journal.pone.0001543', info='totals') 24 | alm_plot(out) 25 | } 26 | } 27 | \references{ 28 | See a tutorial/vignette for alm at 29 | \url{http://ropensci.org/tutorials/alm_tutorial.html} 30 | } 31 | \seealso{ 32 | \code{\link{alm_ids}} which is required to use this function. 33 | } 34 | 35 | -------------------------------------------------------------------------------- /R/alm_requests.R: -------------------------------------------------------------------------------- 1 | #' Retrieve API requests data 2 | #' 3 | #' @export 4 | #' @param key API key. Required. 5 | #' @param url URL for the api requests endpoint. Required. 6 | #' @param ... Curl args to \code{\link[httr]{GET}} 7 | #' @details This function requires authentication via an API key. 8 | #' @examples \dontrun{ 9 | #' out <- alm_requests() 10 | #' out$meta 11 | #' dat <- out$data 12 | #' head( dat ) 13 | #' dat[ dat$db_duration > 100, ] 14 | #' } 15 | alm_requests <- function(key, url = 'http://alm.plos.org/api/v5/api_requests', ...) { 16 | 17 | res <- GET(url, query=list(api_key=getkey(key)), ...) 18 | stop_for_status(res) 19 | out <- jsonlite::fromJSON(content(res, "text"), FALSE) 20 | mm <- out[!names(out) == "data"] 21 | mm[sapply(mm, is.null) == TRUE] <- "none" 22 | meta <- data.frame(mm, stringsAsFactors = FALSE) 23 | data <- do.call(rbind.fill, lapply(out$data, function(x){ 24 | x[sapply(x, is.null) == TRUE] <- "none" 25 | data.frame(x, stringsAsFactors = FALSE) 26 | })) 27 | list(meta=meta, data=data) 28 | } 29 | -------------------------------------------------------------------------------- /man/alm-package.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.1.0): do not edit by hand 2 | % Please edit documentation in R/alm-package.R 3 | \docType{package} 4 | \name{alm-package} 5 | \alias{alm} 6 | \alias{alm-package} 7 | \title{R client for the open source article level metrics Lagotto application.} 8 | \description{ 9 | R client for the open source article level metrics Lagotto application. 10 | } 11 | \details{ 12 | An R interface to the RESTful API from the open source article level metrics 13 | software Lagotto, created by the Public Library of Science (PLOS). A number of 14 | publishers are using Lagotto, so you can drop in a different base URL to the 15 | functions in this package to get to not only PLOS data, but 16 | data for Crossref, and more. 17 | 18 | Authenication was required, but has now been removed going foward in Lagotto. 19 | You only need API keys for a few of the data providers that are running old 20 | versions of Lagotto, and that will change as they upgrade their Lagotto sofware. 21 | } 22 | \author{ 23 | Scott Chamberlain \email{myrmecocystus@gmail.com} 24 | } 25 | \keyword{package} 26 | 27 | -------------------------------------------------------------------------------- /README-NOT.md: -------------------------------------------------------------------------------- 1 | [![Project Status: Unsupported – The project has reached a stable, usable state but the author(s) have ceased all work on it. A new maintainer may be desired.](http://www.repostatus.org/badges/latest/unsupported.svg)](http://www.repostatus.org/#unsupported) 2 | 3 | This package is no longer maintained and has been archived on CRAN. If you're interested in altmetrics you might find these other rOpenSci packages interesting: 4 | 5 | * [`crevents`](https://github.com/ropensci/crevents), Crossref events data R client, 6 | 7 | * [`roadoi`](https://github.com/ropensci/roadoi), that interacts with the Unpaywall API, a simple web-interface which links DOIs and open access versions of scholarly works, 8 | 9 | * [`rAltmetrics`](https://github.com/ropensci/rAltmetric) to query and visualize metrics from altmetric.com. 10 | 11 | ## Code of Conduct 12 | 13 | Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). 14 | By participating in this project you agree to abide by its terms. 15 | 16 | 17 | [![ropensci_footer](https://ropensci.org/public_images/github_footer.png)](https://ropensci.org) 18 | -------------------------------------------------------------------------------- /tests/testthat/test-plot_signposts.R: -------------------------------------------------------------------------------- 1 | # tests for plot_signposts fxn in alm 2 | context("plot_signposts") 3 | 4 | # Plot data from a single identifier gives a bar chart 5 | dat <- alm_signposts(doi="10.1371/journal.pone.0029797") 6 | p <- suppressMessages(plot_signposts(input=dat)) 7 | 8 | # Plot data from many identifiers gives a line chart 9 | dois <- c('10.1371/journal.pone.0001543','10.1371/journal.pone.0040117', 10 | '10.1371/journal.pone.0029797','10.1371/journal.pone.0039395') 11 | dat <- alm_signposts(doi=dois) 12 | q <- suppressMessages(plot_signposts(input=dat)) 13 | 14 | test_that("plot_signposts returns the correct class", { 15 | expect_that(p, is_a("gg")) 16 | expect_that(p, is_a("ggplot")) 17 | expect_that(p$data, is_a("data.frame")) 18 | expect_that(p$layers[[1]], is_a("proto")) 19 | expect_that(p$theme, is_a("theme")) 20 | expect_that(p$coordinates, is_a("cartesian")) 21 | expect_that(q, is_a("gg")) 22 | expect_that(q, is_a("ggplot")) 23 | }) 24 | 25 | test_that("plot_signposts returns the correct dimensions", { 26 | expect_that(nrow(p$data), equals(4)) 27 | expect_that(nrow(q$data), equals(16)) 28 | }) 29 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2 (4.1.0): do not edit by hand 2 | 3 | export(addmissing) 4 | export(alert_classes) 5 | export(alm_alerts) 6 | export(alm_capwords) 7 | export(alm_datepub) 8 | export(alm_events) 9 | export(alm_ids) 10 | export(alm_plot) 11 | export(alm_pubmedcentid) 12 | export(alm_pubmedid) 13 | export(alm_requests) 14 | export(alm_signposts) 15 | export(alm_sources) 16 | export(alm_status) 17 | export(alm_title) 18 | export(alm_totals) 19 | export(almcompact) 20 | export(almdateupdated) 21 | export(almupdated) 22 | export(concat_todf) 23 | export(getkey) 24 | export(plot_density) 25 | export(plot_signposts) 26 | import(ggplot2) 27 | import(httr) 28 | import(jsonlite) 29 | importFrom(grid,gpar) 30 | importFrom(grid,grid.layout) 31 | importFrom(grid,grid.newpage) 32 | importFrom(grid,grid.text) 33 | importFrom(grid,pushViewport) 34 | importFrom(grid,unit) 35 | importFrom(grid,viewport) 36 | importFrom(lubridate,year) 37 | importFrom(plyr,laply) 38 | importFrom(plyr,ldply) 39 | importFrom(plyr,rbind.fill) 40 | importFrom(plyr,round_any) 41 | importFrom(reshape,sort_df) 42 | importFrom(reshape2,melt) 43 | importFrom(stringr,str_replace_all) 44 | importFrom(stringr,str_split) 45 | -------------------------------------------------------------------------------- /R/defunct.R: -------------------------------------------------------------------------------- 1 | #' Get PubMed article ID by inputting the doi for the article. 2 | #' @export 3 | #' @param ... Args 4 | #' @rdname alm-defunct 5 | alm_pubmedid <- function(...) 6 | { 7 | .Defunct("alm_ids", "alm", "Function removed, you can get this info using alm_ids") 8 | } 9 | 10 | #' Get PubMed Central article ID by inputting the doi for the article. 11 | #' @export 12 | #' @rdname alm-defunct 13 | alm_pubmedcentid <- function(...) 14 | { 15 | .Defunct("alm_ids", "alm", "Function removed, you can get this info using alm_ids") 16 | } 17 | 18 | #' Date when alt-metrics for the article (by DOI) data was last updated. 19 | #' @export 20 | #' @rdname alm-defunct 21 | almupdated <- function(...) { 22 | .Defunct("alm_ids", "alm", "Function removed, you can get this info using alm_ids") 23 | } 24 | 25 | #' Get the date when article was last updated. 26 | #' @export 27 | #' @rdname alm-defunct 28 | almdateupdated <- function(...) { 29 | .Defunct("alm_ids", "alm", "Function removed, you can get this info using alm_ids") 30 | } 31 | 32 | 33 | #' Alt-metrics total citations from all sources. 34 | #' @export 35 | #' @rdname alm-defunct 36 | alm_totals <- function(...) 37 | { 38 | .Defunct("alm_ids", "alm", "Function removed, you can get this info using alm_ids") 39 | } 40 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | environment: 2 | R_CHECK_ARGS: --no-build-vignettes --no-manual 3 | 4 | init: 5 | ps: | 6 | $ErrorActionPreference = "Stop" 7 | Invoke-WebRequest http://raw.github.com/krlmlr/r-appveyor/master/scripts/appveyor-tool.ps1 -OutFile "..\appveyor-tool.ps1" 8 | Import-Module '..\appveyor-tool.ps1' 9 | 10 | install: 11 | ps: Bootstrap 12 | 13 | build_script: 14 | - travis-tool.sh install_deps 15 | 16 | test_script: 17 | - travis-tool.sh run_tests 18 | 19 | on_failure: 20 | - travis-tool.sh dump_logs 21 | 22 | notifications: 23 | - provider: Slack 24 | auth_token: 25 | secure: S3AcHEoJHUtahR5N8ConStS8oV/+x34tS1bDGM3OD0QxDKBBxufeiMmXQsId1gZu 26 | channel: builds 27 | 28 | artifacts: 29 | - path: '*.Rcheck\**\*.log' 30 | name: Logs 31 | 32 | - path: '*.Rcheck\**\*.out' 33 | name: Logs 34 | 35 | - path: '*.Rcheck\**\*.fail' 36 | name: Logs 37 | 38 | - path: '*.Rcheck\**\*.Rout' 39 | name: Logs 40 | 41 | - path: '\*_*.tar.gz' 42 | name: tar 43 | 44 | - path: '\*_*.zip' 45 | name: zip 46 | 47 | deploy: 48 | - provider: S3 49 | access_key_id: AKIAI6F2ZOASYNIRGW6A 50 | secret_access_key: 51 | secure: tghGGvPU9AQKRPhkQTuaGsAGmNrfRtT1VuAo5OOOMdZnEctxSn1A/Snp2yEwjZ85 52 | region: us-west-2 53 | bucket: ropensci-windows 54 | artifact: zip 55 | set_public: true 56 | 57 | -------------------------------------------------------------------------------- /R/alm_plot.R: -------------------------------------------------------------------------------- 1 | #' Plot results of a call to the alm function. 2 | #' 3 | #' @import ggplot2 4 | #' @importFrom grid grid.newpage pushViewport viewport grid.layout 5 | #' @importFrom reshape2 melt 6 | #' @importFrom plyr ldply 7 | #' @export 8 | #' 9 | #' @param dat Output from \code{alm_ids} (character) 10 | #' @return A ggplot2 bar plot for `totalmetrics` or line plot for `history`. 11 | #' @seealso \code{\link{alm_ids}} which is required to use this function. 12 | #' @references See a tutorial/vignette for alm at 13 | #' \url{http://ropensci.org/tutorials/alm_tutorial.html} 14 | #' @examples \dontrun{ 15 | #' out <- alm_ids(doi='10.1371/journal.pone.0001543', info='detail') 16 | #' alm_plot(out) 17 | #' # works from info=totals too 18 | #' out <- alm_ids(doi='10.1371/journal.pone.0001543', info='totals') 19 | #' alm_plot(out) 20 | #' } 21 | alm_plot <- function(dat){ 22 | .id <- value <- variable <- dates <- totals <- NULL 23 | 24 | if("totals" %in% names(dat$data)){ 25 | dat_m <- melt(dat$data$totals, id.vars=".id") 26 | } else { 27 | dat_m <- melt(dat$data, id.vars=".id") 28 | } 29 | dat_m <- na.omit(dat_m) 30 | ggplot(dat_m, aes(x = .id, y = value, fill = variable)) + 31 | geom_bar(position="dodge", stat="identity") + 32 | theme_bw(base_size=18) + 33 | coord_flip() + 34 | scale_fill_discrete("Metric") + 35 | labs(y = 'Count') 36 | } 37 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: alm 2 | Title: R Client for the Lagotto Altmetrics Platform 3 | Description: An R interface to the open source article level metrics platform 4 | created by the Public Library 5 | of Science (PLOS). A number of publishers are using the open source app 6 | created by PLOS, so you can drop in a different base URL to the functions 7 | in this package to get to not only PLOS data, but data for Crossref, 8 | and more as the open source PLOS software is used. 9 | Version: 0.4.1 10 | License: MIT + file LICENSE 11 | Authors@R: c(person("Scott", "Chamberlain", role = c("aut", "cre"), 12 | email = "myrmecocystus@gmail.com"), 13 | person("Carl", "Boettiger", role = "aut", 14 | email = "cboettig@gmail.com"), 15 | person("Karthik", "Ram", role = "aut", 16 | email = "karthik.ram@gmail.com"), 17 | person("Fenner", "Martin", role = "aut", 18 | email = "mfenner.ram@plos.org")) 19 | URL: https://github.com/ropensci/alm 20 | BugReports: http://www.github.com/ropensci/alm/issues 21 | LazyData: true 22 | VignetteBuilder: knitr 23 | Roxygen: list(wrap = FALSE) 24 | Imports: 25 | ggplot2, 26 | plyr, 27 | stringr, 28 | reshape, 29 | reshape2, 30 | httr, 31 | grid, 32 | jsonlite, 33 | lubridate 34 | Suggests: 35 | testthat, 36 | roxygen2, 37 | rplos, 38 | knitr 39 | -------------------------------------------------------------------------------- /man/alm-defunct.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.1.0): do not edit by hand 2 | % Please edit documentation in R/alm-package.R, R/defunct.R 3 | \name{alm-defunct} 4 | \alias{alm-defunct} 5 | \alias{alm_pubmedcentid} 6 | \alias{alm_pubmedid} 7 | \alias{alm_totals} 8 | \alias{almdateupdated} 9 | \alias{almupdated} 10 | \title{Defunct functions in alm} 11 | \usage{ 12 | alm_pubmedid(...) 13 | 14 | alm_pubmedcentid(...) 15 | 16 | almupdated(...) 17 | 18 | almdateupdated(...) 19 | 20 | alm_totals(...) 21 | } 22 | \arguments{ 23 | \item{...}{Args} 24 | } 25 | \description{ 26 | \itemize{ 27 | \item \code{\link{alm_pubmedid}}: Function removed, you can get this info using alm_ids 28 | \item \code{\link{alm_pubmedcentid}}: Function removed, you can get this info using alm_ids 29 | \item \code{\link{almupdated}}: Function removed, you can get this info using alm_ids 30 | \item \code{\link{almdateupdated}}: Function removed, you can get this info using alm_ids 31 | \item \code{\link{alm_totals}}: Function removed, you can get this info using alm_ids 32 | } 33 | 34 | Get PubMed article ID by inputting the doi for the article. 35 | 36 | Get PubMed Central article ID by inputting the doi for the article. 37 | 38 | Date when alt-metrics for the article (by DOI) data was last updated. 39 | 40 | Get the date when article was last updated. 41 | 42 | Alt-metrics total citations from all sources. 43 | } 44 | 45 | -------------------------------------------------------------------------------- /CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Code of Conduct 2 | 3 | As contributors and maintainers of this project, we pledge to respect all people who 4 | contribute through reporting issues, posting feature requests, updating documentation, 5 | submitting pull requests or patches, and other activities. 6 | 7 | We are committed to making participation in this project a harassment-free experience for 8 | everyone, regardless of level of experience, gender, gender identity and expression, 9 | sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion. 10 | 11 | Examples of unacceptable behavior by participants include the use of sexual language or 12 | imagery, derogatory comments or personal attacks, trolling, public or private harassment, 13 | insults, or other unprofessional conduct. 14 | 15 | Project maintainers have the right and responsibility to remove, edit, or reject comments, 16 | commits, code, wiki edits, issues, and other contributions that are not aligned to this 17 | Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed 18 | from the project team. 19 | 20 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by 21 | opening an issue or contacting one or more of the project maintainers. 22 | 23 | This Code of Conduct is adapted from the Contributor Covenant 24 | (http:contributor-covenant.org), version 1.0.0, available at 25 | http://contributor-covenant.org/version/1/0/0/ 26 | -------------------------------------------------------------------------------- /R/alm-package.R: -------------------------------------------------------------------------------- 1 | #' R client for the open source article level metrics Lagotto application. 2 | #' 3 | #' An R interface to the RESTful API from the open source article level metrics 4 | #' software Lagotto, created by the Public Library of Science (PLOS). A number of 5 | #' publishers are using Lagotto, so you can drop in a different base URL to the 6 | #' functions in this package to get to not only PLOS data, but 7 | #' data for Crossref, and more. 8 | #' 9 | #' Authenication was required, but has now been removed going foward in Lagotto. 10 | #' You only need API keys for a few of the data providers that are running old 11 | #' versions of Lagotto, and that will change as they upgrade their Lagotto sofware. 12 | #' 13 | #' @name alm-package 14 | #' @aliases alm 15 | #' @docType package 16 | #' @title R client for the open source article level metrics Lagotto application. 17 | #' @author Scott Chamberlain \email{myrmecocystus@@gmail.com} 18 | #' @keywords package 19 | NULL 20 | 21 | #' Defunct functions in alm 22 | #' 23 | #' \itemize{ 24 | #' \item \code{\link{alm_pubmedid}}: Function removed, you can get this info using alm_ids 25 | #' \item \code{\link{alm_pubmedcentid}}: Function removed, you can get this info using alm_ids 26 | #' \item \code{\link{almupdated}}: Function removed, you can get this info using alm_ids 27 | #' \item \code{\link{almdateupdated}}: Function removed, you can get this info using alm_ids 28 | #' \item \code{\link{alm_totals}}: Function removed, you can get this info using alm_ids 29 | #' } 30 | #' 31 | #' @name alm-defunct 32 | NULL 33 | -------------------------------------------------------------------------------- /man/alm_title.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.1.0): do not edit by hand 2 | % Please edit documentation in R/alm_title.R 3 | \name{alm_title} 4 | \alias{alm_title} 5 | \title{Get title of article by inputting the doi for the article.} 6 | \usage{ 7 | alm_title(doi = NULL, pmid = NULL, pmcid = NULL, wos = NULL, 8 | scp = NULL, url = NULL, key = NULL, 9 | api_url = "http://alm.plos.org/api/v5/articles", ...) 10 | } 11 | \arguments{ 12 | \item{doi}{Digital object identifier for an article in PLoS Journals (character)} 13 | 14 | \item{pmid}{PubMed object identifier (numeric)} 15 | 16 | \item{pmcid}{PubMed Central object identifier (numeric)} 17 | 18 | \item{wos}{Web of Science identifier (character)} 19 | 20 | \item{scp}{Scopus identifier (character)} 21 | 22 | \item{url}{Canonical URL (character)} 23 | 24 | \item{key}{your PLoS API key, either enter, or loads from .Rprofile (character)} 25 | 26 | \item{api_url}{API endpoint, defaults to http://alm.plos.org/api/v3/articles (character)} 27 | 28 | \item{...}{optional additional curl options (debugging tools mostly)} 29 | } 30 | \value{ 31 | Title of article, in xml format. 32 | } 33 | \description{ 34 | Get title of article by inputting the doi for the article. 35 | } 36 | \examples{ 37 | \dontrun{ 38 | alm_title(doi='10.1371/journal.pbio.0000012') 39 | dois <- c('10.1371/journal.pone.0026871','10.1371/journal.pone.0048868', 40 | '10.1371/journal.pone.0048705','10.1371/journal.pone.0048731') 41 | alm_title(doi=dois) 42 | } 43 | } 44 | \references{ 45 | See a tutorial/vignette for alm at 46 | \url{http://ropensci.org/tutorials/alm_tutorial.html} 47 | } 48 | 49 | -------------------------------------------------------------------------------- /R/alm_title.R: -------------------------------------------------------------------------------- 1 | #' Get title of article by inputting the doi for the article. 2 | #' 3 | #' @import httr 4 | #' @importFrom stringr str_replace_all 5 | #' @export 6 | #' @param doi Digital object identifier for an article in PLoS Journals (character) 7 | #' @param pmid PubMed object identifier (numeric) 8 | #' @param pmcid PubMed Central object identifier (numeric) 9 | #' @param wos Web of Science identifier (character) 10 | #' @param scp Scopus identifier (character) 11 | #' @param url Canonical URL (character) 12 | #' @param key your PLoS API key, either enter, or loads from .Rprofile (character) 13 | #' @param api_url API endpoint, defaults to http://alm.plos.org/api/v3/articles (character) 14 | #' @param ... optional additional curl options (debugging tools mostly) 15 | #' @return Title of article, in xml format. 16 | #' @references See a tutorial/vignette for alm at 17 | #' \url{http://ropensci.org/tutorials/alm_tutorial.html} 18 | #' @examples \dontrun{ 19 | #' alm_title(doi='10.1371/journal.pbio.0000012') 20 | #' dois <- c('10.1371/journal.pone.0026871','10.1371/journal.pone.0048868', 21 | #' '10.1371/journal.pone.0048705','10.1371/journal.pone.0048731') 22 | #' alm_title(doi=dois) 23 | #' } 24 | 25 | alm_title <- function(doi = NULL, pmid = NULL, pmcid = NULL, wos = NULL, scp = NULL, url = NULL, 26 | key = NULL, api_url = 'http://alm.plos.org/api/v5/articles', ...) 27 | { 28 | .Deprecated(msg = "This function will be deprecated soon") 29 | temp <- alm_ids(doi = doi, pmid = pmid, pmcid = pmcid, wos = wos, scp = scp, url = url, api_url = api_url, 30 | info = "summary", key = key, ...) 31 | if(length(doi) == 1) temp$data$info$title else lapply(temp$data, function(x) x$info$title) 32 | } 33 | -------------------------------------------------------------------------------- /man/plot_signposts.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.1.0): do not edit by hand 2 | % Please edit documentation in R/plot_signposts.R 3 | \name{plot_signposts} 4 | \alias{plot_signposts} 5 | \title{Plot PLOS article-level metrics data.} 6 | \usage{ 7 | plot_signposts(input) 8 | } 9 | \arguments{ 10 | \item{input}{A data.frame from a search from the \code{\link{alm_signposts}} function} 11 | } 12 | \description{ 13 | This can be used in conjuction with the function \code{\link{alm_signposts}}. 14 | } 15 | \details{ 16 | Note that DOIs are the unit of replication of each study. When plotting, 17 | if the prefix is common among all DOIs, then just the end of the DOI, the numeric 18 | part is printed to make plots less ugly. 19 | } 20 | \examples{ 21 | \dontrun{ 22 | # Plot data from a single identifier gives a bar chart 23 | dat <- alm_signposts(doi="10.1371/journal.pone.0029797") 24 | plot_signposts(dat) 25 | 26 | # Plot data from many identifiers gives a line chart 27 | dois <- c('10.1371/journal.pone.0001543','10.1371/journal.pone.0040117', 28 | '10.1371/journal.pone.0029797','10.1371/journal.pone.0039395') 29 | dat <- alm_signposts(doi=dois) 30 | plot_signposts(dat) 31 | 32 | # software lagotto instance 33 | urls <- c("https://github.com/najoshi/sickle","https://github.com/lh3/wgsim", 34 | "https://github.com/jstjohn/SeqPrep") 35 | dat <- alm_signposts(url = urls, api_url = "http://software.lagotto.io/api/v5/articles") 36 | plot_signposts(dat) 37 | 38 | # scopus ids 39 | ids <- c(68049122102, 14044251458, 48349097292, 28444460441) 40 | dat <- alm_signposts(scp = ids) 41 | plot_signposts(dat) 42 | } 43 | } 44 | \references{ 45 | See a tutorial/vignette for alm at 46 | \url{http://ropensci.org/tutorials/alm_tutorial.html} 47 | } 48 | \seealso{ 49 | \code{\link{alm_signposts}} 50 | } 51 | 52 | -------------------------------------------------------------------------------- /man/alm_datepub.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.1.0): do not edit by hand 2 | % Please edit documentation in R/alm_datepub.R 3 | \name{alm_datepub} 4 | \alias{alm_datepub} 5 | \title{Get the date when the article was published.} 6 | \usage{ 7 | alm_datepub(doi = NULL, pmid = NULL, pmcid = NULL, wos = NULL, 8 | scp = NULL, url = NULL, get = NULL, key = NULL, 9 | api_url = "http://alm.plos.org/api/v5/articles", ...) 10 | } 11 | \arguments{ 12 | \item{doi}{Digital object identifier for an article in PLoS Journals (character)} 13 | 14 | \item{pmid}{PubMed object identifier (numeric)} 15 | 16 | \item{pmcid}{PubMed Central object identifier (numeric)} 17 | 18 | \item{wos}{Web of Science identifier (character)} 19 | 20 | \item{scp}{Scopus identifier (character)} 21 | 22 | \item{url}{Canonical URL (character)} 23 | 24 | \item{get}{Get year, month, or day; if unspecified, whole date returned.} 25 | 26 | \item{key}{your PLoS API key, either enter, or loads from .Rprofile (character)} 27 | 28 | \item{api_url}{API endpoint, defaults to http://alm.plos.org/api/v3/articles (character)} 29 | 30 | \item{...}{optional additional curl options (debugging tools mostly)} 31 | } 32 | \value{ 33 | Date when article was published. 34 | } 35 | \description{ 36 | Get the date when the article was published. 37 | } 38 | \examples{ 39 | \dontrun{ 40 | alm_datepub(doi='10.1371/journal.pone.0026871') 41 | alm_datepub('10.1371/journal.pone.0026871', get='year') 42 | 43 | # Provide more than one DOI 44 | dois <- c('10.1371/journal.pone.0026871','10.1371/journal.pone.0048868', 45 | '10.1371/journal.pone.0048705','10.1371/journal.pone.0048731') 46 | alm_datepub(doi=dois, get="month") 47 | } 48 | } 49 | \references{ 50 | See a tutorial/vignette for alm at 51 | \url{http://ropensci.org/tutorials/alm_tutorial.html} 52 | } 53 | 54 | -------------------------------------------------------------------------------- /R/alm_datepub.R: -------------------------------------------------------------------------------- 1 | #' Get the date when the article was published. 2 | #' 3 | #' @import httr 4 | #' @importFrom stringr str_split 5 | #' @export 6 | #' @param doi Digital object identifier for an article in PLoS Journals (character) 7 | #' @param pmid PubMed object identifier (numeric) 8 | #' @param pmcid PubMed Central object identifier (numeric) 9 | #' @param wos Web of Science identifier (character) 10 | #' @param scp Scopus identifier (character) 11 | #' @param url Canonical URL (character) 12 | #' @param get Get year, month, or day; if unspecified, whole date returned. 13 | #' @param key your PLoS API key, either enter, or loads from .Rprofile (character) 14 | #' @param api_url API endpoint, defaults to http://alm.plos.org/api/v3/articles (character) 15 | #' @param ... optional additional curl options (debugging tools mostly) 16 | #' @references See a tutorial/vignette for alm at 17 | #' \url{http://ropensci.org/tutorials/alm_tutorial.html} 18 | #' @return Date when article was published. 19 | #' @examples \dontrun{ 20 | #' alm_datepub(doi='10.1371/journal.pone.0026871') 21 | #' alm_datepub('10.1371/journal.pone.0026871', get='year') 22 | #' 23 | #' # Provide more than one DOI 24 | #' dois <- c('10.1371/journal.pone.0026871','10.1371/journal.pone.0048868', 25 | #' '10.1371/journal.pone.0048705','10.1371/journal.pone.0048731') 26 | #' alm_datepub(doi=dois, get="month") 27 | #' } 28 | 29 | alm_datepub <- function(doi = NULL, pmid = NULL, pmcid = NULL, wos = NULL, scp = NULL, url = NULL, 30 | get = NULL, key = NULL, api_url = 'http://alm.plos.org/api/v5/articles', ...) 31 | { 32 | temp <- alm_ids(doi = doi, pmid = pmid, pmcid = pmcid, wos = wos, scp = scp, url = url, api_url = api_url, 33 | info = "summary", key = key, ...) 34 | if(length(doi) == 1) getdate(temp$data, get) else lapply(temp$data, getdate, get=get) 35 | } 36 | 37 | getdate <- function(x, get) { 38 | date <- x$info$issued 39 | if(is.null(get)) { date } else { 40 | switch(get, 41 | year = as.numeric(strsplit(date,"-")[[1]][1]), 42 | month = as.numeric(strsplit(date,"-")[[1]][2]), 43 | day = as.numeric(strsplit(date,"-")[[1]][3]) 44 | ) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /man-roxygen/alm_params.R: -------------------------------------------------------------------------------- 1 | #' @param doi (character) Digital object identifier for an article in PLoS Journals 2 | #' @param pmid (numeric) PubMed object identifier 3 | #' @param pmcid (numeric) PubMed Central object identifier 4 | #' @param wos (character) Web of Science identifier 5 | #' @param scp (character) Scopus identifier 6 | #' @param url (character) Canonical URL. This is a URL for an object, not the URL for the 7 | #' Lagotto instance (see api_url) 8 | #' @param info One of totals, summary, or detail (default totals + sum_metrics data in a list). 9 | #' Not specifying anything (the default) returns data.frame of totals across 10 | #' data providers. (character). \code{info='detail'} returns all possible data, including slots 11 | #' for info, signposts, totals, and sum_metrics (see the sum_metrics parameter below). 12 | #' IMPORTANT: note, however, that you can only get by day metrics for articles published since 13 | #' May 2014. 14 | #' @param source_id (character) Name of source to get ALM information for. One source only. 15 | #' You can get multiple sources via a for loop or lapply-type call. 16 | #' @param publisher_id (character) Metrics for articles by a given publisher, using the Crossref 17 | #' \code{member_id}. 18 | #' @param key (character) Your API key, either enter, or loads from .Rprofile. Only required for 19 | #' PKP source, not the others. 20 | #' @param total_details (logical) If FALSE (the default) the standard totals data.frame is 21 | #' returned; if TRUE, the totals data is in a wide format with more details 22 | #' about the paper, including publication date, title, etc. If you set this 23 | #' to TRUE, the output should no longer with with \code{\link{alm_plot}}. 24 | #' @param sum_metrics (character) Just like the output you get from setting info='totals', you can 25 | #' get summary metrics by day (sum_metrics='day'), month (sum_metrics='month'), 26 | #' or year (sum_metrics='year'). IMPORTANT: note that you can only get by day metrics for 27 | #' articles published since May 2014. 28 | #' @param api_url (character) API endpoint, defaults to http://alm.plos.org/api/v5/articles 29 | #' @param ... Curl options (debugging tools mostly) passed on to \code{\link[httr]{GET}} 30 | -------------------------------------------------------------------------------- /man/alm_alerts.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.1.0): do not edit by hand 2 | % Please edit documentation in R/alerts.R 3 | \name{alm_alerts} 4 | \alias{alm_alerts} 5 | \title{Retrieve alerts data for article-level metrics (ALM).} 6 | \usage{ 7 | alm_alerts(source_id = NULL, publisher_id = NULL, ids = NULL, 8 | class_name = NULL, level = NULL, q = NULL, unresolved = FALSE, 9 | per_page = 50, page = 1, user = NULL, pwd = NULL, 10 | api_url = "http://alm.plos.org/api/v4/alerts", ...) 11 | } 12 | \arguments{ 13 | \item{source_id}{(character) Source to limtit alert search to.} 14 | 15 | \item{publisher_id}{(character) Metrics for articles by a given publisher, using the Crossref 16 | \code{member_id}.} 17 | 18 | \item{ids}{(character) Article identifiers} 19 | 20 | \item{class_name}{(character) Which error to get} 21 | 22 | \item{level}{(character) Alert level to limit search to. One of ERROR, WARN, INFO, 23 | or FATAL. Default: all.} 24 | 25 | \item{q}{(character) Query terms} 26 | 27 | \item{unresolved}{(logical) Whether to give back unresolved alerts only.} 28 | 29 | \item{per_page}{(integer) Number of records to return. Default: 50. Max: ?} 30 | 31 | \item{page}{(integer) Number from 1 to number of pages} 32 | 33 | \item{user}{(character) Username} 34 | 35 | \item{pwd}{(character) Password} 36 | 37 | \item{api_url}{URL to use.} 38 | 39 | \item{...}{Further args passed to httr::GET} 40 | } 41 | \description{ 42 | Retrieve alerts data for article-level metrics (ALM). 43 | } 44 | \details{ 45 | This function uses the alm.plos.org API by default. You can change which ALM app you use by 46 | specifying the url in the api_url parameter. It will likely be the same as the default 47 | http://alm.plos.org/api/v4/alerts, but just the alm.plos.org part will be different. 48 | 49 | ALM installations on the most current version (3.4.7) can be used in this function, as of 50 | 2014-08-26 those are PLOS, ALM Labs, and Crossref Labs. 51 | } 52 | \examples{ 53 | \dontrun{ 54 | alm_alerts() 55 | alm_alerts(q='mismatch') 56 | alm_alerts(unresolved=TRUE) 57 | alm_alerts(class_name='NoMethodError') 58 | alm_alerts(class_name='ApiResponseTooSlowError') 59 | alm_alerts(level='Error') 60 | alm_alerts(ids="10.1371/journal.pone.0029797") 61 | 62 | # curl debugging 63 | library("httr") 64 | alm_alerts(level='Error', config=verbose()) 65 | 66 | # paging 67 | alm_alerts(per_page=2) 68 | 69 | # by source_id 70 | alm_alerts(source_id = "wos") 71 | 72 | # by publisher_id 73 | alm_alerts(publisher_id = 340) 74 | } 75 | } 76 | 77 | -------------------------------------------------------------------------------- /R/plot_signposts.R: -------------------------------------------------------------------------------- 1 | #' Plot PLOS article-level metrics data. 2 | #' 3 | #' This can be used in conjuction with the function \code{\link{alm_signposts}}. 4 | #' 5 | #' @import ggplot2 6 | #' @importFrom reshape2 melt 7 | #' @export 8 | #' 9 | #' @param input A data.frame from a search from the \code{\link{alm_signposts}} function 10 | #' @details Note that DOIs are the unit of replication of each study. When plotting, 11 | #' if the prefix is common among all DOIs, then just the end of the DOI, the numeric 12 | #' part is printed to make plots less ugly. 13 | #' @seealso \code{\link{alm_signposts}} 14 | #' @references See a tutorial/vignette for alm at 15 | #' \url{http://ropensci.org/tutorials/alm_tutorial.html} 16 | #' @examples \dontrun{ 17 | #' # Plot data from a single identifier gives a bar chart 18 | #' dat <- alm_signposts(doi="10.1371/journal.pone.0029797") 19 | #' plot_signposts(dat) 20 | #' 21 | #' # Plot data from many identifiers gives a line chart 22 | #' dois <- c('10.1371/journal.pone.0001543','10.1371/journal.pone.0040117', 23 | #' '10.1371/journal.pone.0029797','10.1371/journal.pone.0039395') 24 | #' dat <- alm_signposts(doi=dois) 25 | #' plot_signposts(dat) 26 | #' 27 | #' # software lagotto instance 28 | #' urls <- c("https://github.com/najoshi/sickle","https://github.com/lh3/wgsim", 29 | #' "https://github.com/jstjohn/SeqPrep") 30 | #' dat <- alm_signposts(url = urls, api_url = "http://software.lagotto.io/api/v5/articles") 31 | #' plot_signposts(dat) 32 | #' 33 | #' # scopus ids 34 | #' ids <- c(68049122102, 14044251458, 48349097292, 28444460441) 35 | #' dat <- alm_signposts(scp = ids) 36 | #' plot_signposts(dat) 37 | #' } 38 | 39 | plot_signposts <- function(input){ 40 | if(!is.data.frame(input)) 41 | stop("object passed to input must be a data.frame") 42 | 43 | if(nrow(input)==1){ 44 | df <- melt(input) 45 | ggplot(df, aes(variable, value)) + 46 | theme_grey(base_size=16) + 47 | geom_bar(stat="identity") + 48 | labs(x="",y="") 49 | } else { 50 | input <- stripdois(input) 51 | df <- melt(input) 52 | ggplot(df, aes(id, value)) + 53 | theme_grey(base_size=16) + 54 | geom_bar(stat="identity") + 55 | facet_wrap(~variable, scales="free") + 56 | labs(x="",y="") 57 | } 58 | } 59 | 60 | stripdois <- function(x){ 61 | if(strsplit(x$id[1], '/')[[1]][1] == "url"){ 62 | x$id <- sapply(strsplit(as.character(x$id), "/"), "[[", 6) 63 | x 64 | } else { 65 | x$id <- sapply(strsplit(as.character(x$id), "\\."), "[[", 4) 66 | x 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /inst/ignore/plot_scatter.R: -------------------------------------------------------------------------------- 1 | #' Bubble chart 2 | #' @import ggplot2 scales 3 | #' @importFrom grid unit grid.text gpar viewport grid.newpage 4 | #' @importFrom reshape2 melt 5 | #' @importFrom plyr round_any 6 | #' @importFrom lubridate year 7 | #' @param input A data.frame, usuaally from a call to \code{link{alm}}. 8 | #' @param source Data source (column) to plot. Can be a single element, or a 9 | #' character vector. 10 | #' @param color Color of the density plot and the title. Can be a hex color or 11 | #' rgb, etc. 12 | #' @param title Title for the plot, in top matching the color of the density plot. 13 | #' @param description Optional description, subtending the title. 14 | #' @param symbol Symbol type, see ?pch for possible values. 15 | #' @author Martin Fenner, mfenner@@plos.org, modified by Scott Chamberlain 16 | #' @examples \dontrun{ 17 | #' library(rplos); library(plyr); library(scales) 18 | dois <- searchplos(terms='*:*', fields="id", 19 | toquery=list('cross_published_journal_key:PLoSONE', 'doc_type:full', 20 | 'publication_date:[2010-01-01T00:00:00Z TO 2010-12-31T23:59:59Z]'), limit=500) 21 | alm <- alm(doi=do.call(c,dois$id), total_details=TRUE) 22 | alm <- ldply(alm) 23 | plot_scatter(input=alm, plotbyvar="scopus_citations") 24 | plot_scatter(input=alm, plotbyvar="pmc_total") 25 | 26 | # plot_scatter(input=alm2, plotbyvar="scopus") 27 | 28 | dois <- searchplos(terms='*:*', fields="id", 29 | toquery=list('cross_published_journal_key:PLoSONE', 'doc_type:full'), limit=100) 30 | alm <- alm(doi=do.call(c,dois$id), total_details=TRUE) 31 | alm <- ldply(alm) 32 | plot_scatter(input=alm, plotbyvar="scopus_citations") 33 | #' } 34 | #' @export 35 | 36 | plot_scatter <- function(input, plotbyvar, color="#1ebd21") 37 | { 38 | theme_scatter <- function(){ 39 | list(theme_bw(base_size=16), 40 | theme(panel.grid.major=element_blank(), 41 | panel.grid.minor=element_blank(), 42 | panel.border = theme_blank(), 43 | legend.position="none", 44 | axis.line = theme_segment(colour = "black")), 45 | labs(x="", y="")) 46 | } 47 | 48 | if(!inherits(input,"data.frame")) 49 | stop("input must be a data.frame") 50 | 51 | input <- input[order(input[,plotbyvar], decreasing = TRUE),] 52 | input$publication_date <- as.Date(input$publication_date) 53 | 54 | ggplot(input, aes_string(x="publication_date", y="counter_total", size=plotbyvar)) + 55 | geom_point(colour=color) + 56 | scale_x_date(labels = date_format("%b/%y")) + 57 | theme_scatter() + 58 | labs(y="Views",x="") 59 | } -------------------------------------------------------------------------------- /inst/ignore/plot_timeline.R: -------------------------------------------------------------------------------- 1 | # plot_timeline <- function() 2 | # { 3 | # message("Function now written yet") 4 | # } 5 | # library(alm); library(reshape2); library(reshape); library(rCharts) 6 | # dois <- c('10.1371/journal.pone.0001543','10.1371/journal.pone.0040117','10.1371/journal.pone.0039395') 7 | # out <- alm(doi=dois, info="history") 8 | # out2 <- lapply(out, function(x) x[ x$.id == "pmc", c("dates","totals")]) 9 | # temp <- merge(out2[[1]], out2[[2]], all = TRUE, sort = FALSE, by="dates") 10 | # temp <- merge(temp, out2[[3]], all = TRUE, sort = FALSE, by="dates") 11 | # names(temp)[2:4] <- sapply(dois[1:3], function(x) strsplit(x, "\\.")[[1]][[4]], USE.NAMES=FALSE) 12 | # # out <- alm(doi="10.1371/journal.pone.0029797", info="history") 13 | # # out2 <- dcast(out, dates ~ .id, fun.aggregate=sum) 14 | # m1 <- mPlot(x = "dates", y = names(temp)[2:4], type = "Line", data = temp) 15 | # m1$set(pointSize = 0, lineWidth = 1) 16 | # m1 17 | 18 | 19 | ##### 20 | # library(alm); library(reshape2); library(reshape); library(rCharts) 21 | # dois <- c('10.1371/journal.pone.0001543','10.1371/journal.pone.0040117','10.1371/journal.pone.0039395') 22 | # out <- alm(doi=dois, info="history") 23 | # out2 <- lapply(out, function(x) x[ x$.id == "counter", c("dates","totals")]) 24 | # 25 | # formatt <- function(x){ 26 | # x$dates <- as.Date(x$dates) 27 | # tt <- sort_df(x, "dates") 28 | # tt$dates <- as.character(tt$dates) 29 | # tt[is.na(tt)] <- 0 30 | # tt 31 | # } 32 | # 33 | # out3 <- lapply(out2, formatt) 34 | # 35 | # h1 <- hPlot( 36 | # totals ~ dates, 37 | # data = out3[[2]], 38 | # type = "column" 39 | # ) 40 | # h1$xAxis(labels ='{enabled: false}', ticks = '{enabled: false}') 41 | # h1$yAxis(gridLineWidth = 0, title = 'false') 42 | # # h1$yAxis(gridLineWidth = 0, title = 'false', labels = '{step: 2}') 43 | # h1$chart(width=900, height=200) 44 | # h1 45 | # h1$plotOptions(series = '{color: #}') 46 | # h$tooltip() 47 | # h1$print() 48 | # h1$colors("#799AA2") 49 | # h1$plotOptions(column = '{colorByPoint: true}') 50 | 51 | 52 | # m1 <- mPlot(x = "date", y = c("psavert", "uempmed"), type = "Bar", data = econ) 53 | # m1 54 | # 55 | # 56 | # h1 <- Highcharts$new() 57 | # h1$chart(type = "bar") 58 | # h1$series(data = c(1, 3, 2, 4, 5, 4, 6, 2, 3, 5, NA), dashStyle = "longdash") 59 | # h1$series(data = c(NA, 4, 1, 3, 4, 2, 9, 1, 2, 3, 4), dashStyle = "shortdot") 60 | # h1$legend(symbolWidth = 80) 61 | # h1 62 | # 63 | # df=data.frame(name=c("US", "GB", "RU"), value=c(5,1,8)) 64 | # df <- df[order(df$value),] 65 | # h1 <- hPlot( 66 | # value ~ name, 67 | # data = df, 68 | # type = "column" 69 | # ) 70 | # h1 -------------------------------------------------------------------------------- /man/alm_sources.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.1.0): do not edit by hand 2 | % Please edit documentation in R/alm_sources.R 3 | \name{alm_sources} 4 | \alias{alm_sources} 5 | \title{Retrieve PLoS article-level metrics (ALM) by source.} 6 | \usage{ 7 | alm_sources(source_id = "crossref", info = "totals", key = NULL, 8 | total_details = FALSE, sum_metrics = NULL, limit = 50, page = 1, 9 | url = "http://alm.plos.org/api/v5/articles", ...) 10 | } 11 | \arguments{ 12 | \item{source_id}{(character) Name of source to get ALM information for. One source only. 13 | You can get multiple sources via a for loop or lapply-type call.} 14 | 15 | \item{info}{One of totals, summary, or detail (default totals + sum_metrics data in a list). 16 | Not specifying anything (the default) returns data.frame of totals across 17 | data providers. (character)} 18 | 19 | \item{key}{(character) Your API key, either enter, or loads from .Rprofile. Only required for 20 | PKP source, not the others.} 21 | 22 | \item{total_details}{If FALSE (the default) the standard totals data.frame is 23 | returned; if TRUE, the totals data is in a wide format with more details 24 | about the paper, including publication date, title, etc. If you set this 25 | to TRUE, the output should no longer with with \code{\link{alm_plot}}.} 26 | 27 | \item{sum_metrics}{Just like the output you get from setting info='totals', you can 28 | get summary metrics by day (sum_metrics='day'), month (sum_metrics='month'), 29 | or year (sum_metrics='year').} 30 | 31 | \item{limit}{(integer) Number from 1 to infinity. This doubles as the rows parameter, which is 32 | what's called internally to the API service. The max results per page is 50, so if you use a 33 | value > 50, then we essentially loop through to get all the results you want.} 34 | 35 | \item{page}{(integer) Number from 1 to infinity.} 36 | 37 | \item{url}{API endpoint, defaults to http://alm.plos.org/api/v3/articles (character)} 38 | 39 | \item{...}{optional additional curl options (debugging tools mostly)} 40 | } 41 | \description{ 42 | See details for more information. 43 | } 44 | \examples{ 45 | \dontrun{ 46 | alm_sources() 47 | alm_sources(source_id='mendeley') 48 | alm_sources(source_id='scopus', info='summary') 49 | lapply(c('mendeley','twitter'), alm_sources, limit = 2) 50 | alm_sources(source_id='mendeley', limit=2) 51 | alm_sources(source_id='mendeley', limit=2, page=2) 52 | alm_sources(source_id='mendeley', limit=200) 53 | 54 | alm_sources(source_id='mendeley', info='summary') 55 | } 56 | } 57 | \references{ 58 | See a tutorial/vignette for alm at 59 | \url{http://ropensci.org/tutorials/alm_tutorial.html} 60 | } 61 | 62 | -------------------------------------------------------------------------------- /man/alm_signposts.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.1.0): do not edit by hand 2 | % Please edit documentation in R/alm_signposts.R 3 | \name{alm_signposts} 4 | \alias{alm_signposts} 5 | \title{Retrieve PLOS article-level metrics signposts.} 6 | \usage{ 7 | alm_signposts(doi = NULL, pmid = NULL, pmcid = NULL, wos = NULL, 8 | scp = NULL, url = NULL, source_id = NULL, key = NULL, 9 | api_url = "http://alm.plos.org/api/v5/articles", ...) 10 | } 11 | \arguments{ 12 | \item{doi}{Digital object identifier for an article in PLoS Journals (character)} 13 | 14 | \item{pmid}{PubMed object identifier (numeric)} 15 | 16 | \item{pmcid}{PubMed Central object identifier (numeric)} 17 | 18 | \item{wos}{Web of Science identifier (character)} 19 | 20 | \item{scp}{Scopus identifier (character)} 21 | 22 | \item{url}{Canonical URL (character)} 23 | 24 | \item{source_id}{(character) Name of source to get ALM information for. One source only. 25 | You can get multiple sources via a for loop or lapply-type call.} 26 | 27 | \item{key}{your PLoS API key, either enter, or loads from .Rprofile (character)} 28 | 29 | \item{api_url}{API endpoint, defaults to http://alm.plos.org/api/v3/articles (character)} 30 | 31 | \item{...}{optional additional curl options (debugging tools mostly)} 32 | } 33 | \value{ 34 | A data.frame of the signpost numbers for the searched object, and DOIs. 35 | } 36 | \description{ 37 | This includes: 38 | \itemize{ 39 | \item viewed: counter, and pmc (PLOS only) 40 | \item saved: mendeley, and citeulike 41 | \item discussed: facebook, and twitter at PLOS 42 | \item cited: crossref, and scopus at PLOS 43 | } 44 | } 45 | \details{ 46 | This is just a wrapper around the function \code{\link{alm_ids}}, forcing 47 | info="summary", then coercing signposts data to a data.frame. 48 | } 49 | \examples{ 50 | \dontrun{ 51 | # The default call with either doi, pmid, pmcid, wos, scp, or url without specifying 52 | # an argument for info 53 | alm_signposts(doi="10.1371/journal.pone.0029797") 54 | 55 | # Many DOIs 56 | dois <- c('10.1371/journal.pone.0001543','10.1371/journal.pone.0040117', 57 | '10.1371/journal.pone.0029797','10.1371/journal.pone.0039395') 58 | alm_signposts(doi=dois) 59 | 60 | # A single PubMed ID (pmid) 61 | alm_signposts(pmid=22590526) 62 | 63 | # A single PubMed Central ID (pmcid) 64 | alm_signposts(pmcid=212692) 65 | 66 | # A single PubMed Central ID (pmcid) 67 | alm_signposts(source_id = "crossref") 68 | 69 | # Curl debugging 70 | library('httr') 71 | alm_signposts(pmid=22590526, config=verbose()) 72 | } 73 | } 74 | \references{ 75 | See a tutorial/vignette for alm at 76 | \url{http://ropensci.org/tutorials/alm_tutorial.html} 77 | } 78 | \seealso{ 79 | \code{\link{alm_ids}}, \code{\link{plot_signposts}} 80 | } 81 | 82 | -------------------------------------------------------------------------------- /man/plot_density.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.1.0): do not edit by hand 2 | % Please edit documentation in R/plot_density.R 3 | \name{plot_density} 4 | \alias{plot_density} 5 | \title{Density and histogram plots from PLOS Article Level Metrics data} 6 | \usage{ 7 | plot_density(input, source = "scopus_total", color = "#1447f2", 8 | title = "", description = "", plot_type = "density") 9 | } 10 | \arguments{ 11 | \item{input}{A data.frame, usuaally from a call to \code{link{alm}}.} 12 | 13 | \item{source}{Data source (column) to plot. Can be a single element, or a 14 | character vector.} 15 | 16 | \item{color}{Color of the density plot and the title. Can be a hex color or 17 | rgb, etc.} 18 | 19 | \item{title}{Title for the plot, in top matching the color of the density plot.} 20 | 21 | \item{description}{Optional description, subtending the title.} 22 | 23 | \item{plot_type}{Type of plot, one of density (default) or histogram.} 24 | } 25 | \description{ 26 | Density and histogram plots from PLOS Article Level Metrics data 27 | } 28 | \examples{ 29 | \dontrun{ 30 | library('rplos'); library('plyr') 31 | dois <- searchplos(q='*:*', fl="id", 32 | fq=list( 33 | 'cross_published_journal_key:PLoSONE', 34 | 'doc_type:full', 35 | 'publication_date:[2010-01-01T00:00:00Z TO 2010-12-31T23:59:59Z]', 36 | '-article_type:correction'), 37 | limit=50) 38 | dois <- dois$data$id[!grepl("annotation", dois$data$id)] 39 | alm <- alm_ids(doi=dois, total_details=TRUE) 40 | alm <- ldply(alm$data, data.frame) 41 | plot_density(alm) 42 | plot_density(alm, color="#DCA121") 43 | plot_density(alm, title="Scopus citations from 2010") 44 | plot_density(alm, title="Scopus citations from 2010", description="Probablity of 45 | X number of citations for a paper") 46 | plot_density(alm, description="Probablity of X number of citations for a paper") 47 | plot_density(alm, source="crossref_total") 48 | plot_density(alm, source="twitter_total") 49 | plot_density(alm, source="counter_total") 50 | plot_density(alm, source=c("counter_total","facebook_likes")) 51 | plot_density(alm, source=c("counter_total","facebook_likes")) 52 | plot_density(alm, source=c("counter_total","facebook_likes", "twitter_total")) 53 | plot_density(alm, source=c("counter_total","crossref_total","twitter_total"), 54 | color=c("#DBAC6A", "#E09B33", "#A06D34")) 55 | plot_density(alm, source=c("counter_total","crossref_total", 56 | "twitter_total")) 57 | plot_density(alm, source=c("counter_total","crossref_total"), 58 | title="Counter and Crossref") 59 | plot_density(alm, source=c("counter_total","crossref_total", 60 | "twitter_total"), color=c("#83DFB4","#EFA5A5","#CFD470")) 61 | } 62 | } 63 | \author{ 64 | Martin Fenner, mfenner@plos.org, modified by Scott Chamberlain 65 | } 66 | \references{ 67 | See a tutorial/vignette for alm at 68 | \url{http://ropensci.org/tutorials/alm_tutorial.html} 69 | } 70 | 71 | -------------------------------------------------------------------------------- /R/alm_signposts.R: -------------------------------------------------------------------------------- 1 | #' Retrieve PLOS article-level metrics signposts. 2 | #' 3 | #' This includes: 4 | #' \itemize{ 5 | #' \item viewed: counter, and pmc (PLOS only) 6 | #' \item saved: mendeley, and citeulike 7 | #' \item discussed: facebook, and twitter at PLOS 8 | #' \item cited: crossref, and scopus at PLOS 9 | #' } 10 | #' 11 | #' @export 12 | #' @param doi Digital object identifier for an article in PLoS Journals (character) 13 | #' @param pmid PubMed object identifier (numeric) 14 | #' @param pmcid PubMed Central object identifier (numeric) 15 | #' @param wos Web of Science identifier (character) 16 | #' @param scp Scopus identifier (character) 17 | #' @param url Canonical URL (character) 18 | #' @param api_url API endpoint, defaults to http://alm.plos.org/api/v3/articles (character) 19 | #' @param source_id (character) Name of source to get ALM information for. One source only. 20 | #' You can get multiple sources via a for loop or lapply-type call. 21 | #' @param key your PLoS API key, either enter, or loads from .Rprofile (character) 22 | #' @param ... optional additional curl options (debugging tools mostly) 23 | #' 24 | #' @details This is just a wrapper around the function \code{\link{alm_ids}}, forcing 25 | #' info="summary", then coercing signposts data to a data.frame. 26 | #' @seealso \code{\link{alm_ids}}, \code{\link{plot_signposts}} 27 | #' @return A data.frame of the signpost numbers for the searched object, and DOIs. 28 | #' @references See a tutorial/vignette for alm at 29 | #' \url{http://ropensci.org/tutorials/alm_tutorial.html} 30 | #' @examples \dontrun{ 31 | #' # The default call with either doi, pmid, pmcid, wos, scp, or url without specifying 32 | #' # an argument for info 33 | #' alm_signposts(doi="10.1371/journal.pone.0029797") 34 | #' 35 | #' # Many DOIs 36 | #' dois <- c('10.1371/journal.pone.0001543','10.1371/journal.pone.0040117', 37 | #' '10.1371/journal.pone.0029797','10.1371/journal.pone.0039395') 38 | #' alm_signposts(doi=dois) 39 | #' 40 | #' # A single PubMed ID (pmid) 41 | #' alm_signposts(pmid=22590526) 42 | #' 43 | #' # A single PubMed Central ID (pmcid) 44 | #' alm_signposts(pmcid=212692) 45 | #' 46 | #' # A single PubMed Central ID (pmcid) 47 | #' alm_signposts(source_id = "crossref") 48 | #' 49 | #' # Curl debugging 50 | #' library('httr') 51 | #' alm_signposts(pmid=22590526, config=verbose()) 52 | #' } 53 | 54 | alm_signposts <- function(doi = NULL, pmid = NULL, pmcid = NULL, wos = NULL, scp = NULL, url = NULL, 55 | source_id = NULL, key = NULL, api_url = 'http://alm.plos.org/api/v5/articles', ...) 56 | { 57 | temp <- alm_ids(doi = doi, pmid = pmid, pmcid = pmcid, wos = wos, scp = scp, url = url, api_url = api_url, 58 | info = "summary", source_id = source_id, key = key, ...) 59 | if( !is.null(temp$data[['signposts']]) ){ 60 | temp$data[['signposts']] 61 | } else 62 | { 63 | out <- lapply(temp$data, '[[', 'signposts') 64 | do.call(rbind, unname(out)) 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /R/alerts.R: -------------------------------------------------------------------------------- 1 | #' Retrieve alerts data for article-level metrics (ALM). 2 | #' 3 | #' @import httr jsonlite 4 | #' @export 5 | #' 6 | #' @param source_id (character) Source to limtit alert search to. 7 | #' @param publisher_id (character) Metrics for articles by a given publisher, using the Crossref 8 | #' \code{member_id}. 9 | #' @param ids (character) Article identifiers 10 | #' @param class_name (character) Which error to get 11 | #' @param level (character) Alert level to limit search to. One of ERROR, WARN, INFO, 12 | #' or FATAL. Default: all. 13 | #' @param q (character) Query terms 14 | #' @param unresolved (logical) Whether to give back unresolved alerts only. 15 | #' @param per_page (integer) Number of records to return. Default: 50. Max: ? 16 | #' @param page (integer) Number from 1 to number of pages 17 | #' @param user (character) Username 18 | #' @param pwd (character) Password 19 | #' @param api_url URL to use. 20 | #' @param ... Further args passed to httr::GET 21 | #' 22 | #' @details 23 | #' This function uses the alm.plos.org API by default. You can change which ALM app you use by 24 | #' specifying the url in the api_url parameter. It will likely be the same as the default 25 | #' http://alm.plos.org/api/v4/alerts, but just the alm.plos.org part will be different. 26 | #' 27 | #' ALM installations on the most current version (3.4.7) can be used in this function, as of 28 | #' 2014-08-26 those are PLOS, ALM Labs, and Crossref Labs. 29 | #' 30 | #' @examples \dontrun{ 31 | #' alm_alerts() 32 | #' alm_alerts(q='mismatch') 33 | #' alm_alerts(unresolved=TRUE) 34 | #' alm_alerts(class_name='NoMethodError') 35 | #' alm_alerts(class_name='ApiResponseTooSlowError') 36 | #' alm_alerts(level='Error') 37 | #' alm_alerts(ids="10.1371/journal.pone.0029797") 38 | #' 39 | #' # curl debugging 40 | #' library("httr") 41 | #' alm_alerts(level='Error', config=verbose()) 42 | #' 43 | #' # paging 44 | #' alm_alerts(per_page=2) 45 | #' 46 | #' # by source_id 47 | #' alm_alerts(source_id = "wos") 48 | #' 49 | #' # by publisher_id 50 | #' alm_alerts(publisher_id = 340) 51 | #' } 52 | 53 | alm_alerts <- function(source_id=NULL, publisher_id=NULL, ids=NULL, class_name=NULL, level=NULL, q=NULL, 54 | unresolved=FALSE, per_page=50, page=1, user=NULL, pwd=NULL, api_url='http://alm.plos.org/api/v4/alerts', ...) 55 | { 56 | if(length(source_id) > 1) stop("You can only supply one source_id") 57 | if(length(publisher_id) > 1) stop("You can only supply one publisher_id") 58 | 59 | user <- getuserinfo(user, pwd) 60 | args <- alm_compact(list(q=q, source_id=source_id, publisher_id=publisher_id, 61 | class_name=class_name, level=if(!is.null(level)) toupper(level) else NULL, 62 | unresolved=if(unresolved) 1 else NULL, ids=ids, per_page=per_page, page=page)) 63 | furtherargs <- list(...) 64 | tt <- GET(api_url, 65 | query=args, 66 | config=c(authenticate(user[1], user[2]), furtherargs[['config']])) 67 | stop_for_status(tt) 68 | res <- content(tt, as = "text") 69 | tmp <- jsonlite::fromJSON(res) 70 | list(meta=data.frame(tmp[names(tmp) %in% c("total","total_pages","page") ], stringsAsFactors = FALSE), 71 | error=tmp$error, 72 | data=tmp$data) 73 | } 74 | 75 | getuserinfo <- function(x=NULL, y=NULL){ 76 | c(if(is.null(x)) getOption("almv4_user") else x, if(is.null(y)) getOption("almv4_pwd") else y) 77 | } 78 | 79 | alm_compact <- function(l) Filter(Negate(is.null), l) 80 | -------------------------------------------------------------------------------- /R/alm_sources.R: -------------------------------------------------------------------------------- 1 | #' Retrieve PLoS article-level metrics (ALM) by source. 2 | #' 3 | #' See details for more information. 4 | #' 5 | #' @importFrom plyr round_any 6 | #' @export 7 | #' 8 | #' @param source_id (character) Name of source to get ALM information for. One source only. 9 | #' You can get multiple sources via a for loop or lapply-type call. 10 | #' @param info One of totals, summary, or detail (default totals + sum_metrics data in a list). 11 | #' Not specifying anything (the default) returns data.frame of totals across 12 | #' data providers. (character) 13 | #' @param key (character) Your API key, either enter, or loads from .Rprofile. Only required for 14 | #' PKP source, not the others. 15 | #' @param total_details If FALSE (the default) the standard totals data.frame is 16 | #' returned; if TRUE, the totals data is in a wide format with more details 17 | #' about the paper, including publication date, title, etc. If you set this 18 | #' to TRUE, the output should no longer with with \code{\link{alm_plot}}. 19 | #' @param sum_metrics Just like the output you get from setting info='totals', you can 20 | #' get summary metrics by day (sum_metrics='day'), month (sum_metrics='month'), 21 | #' or year (sum_metrics='year'). 22 | #' @param limit (integer) Number from 1 to infinity. This doubles as the rows parameter, which is 23 | #' what's called internally to the API service. The max results per page is 50, so if you use a 24 | #' value > 50, then we essentially loop through to get all the results you want. 25 | #' @param page (integer) Number from 1 to infinity. 26 | #' @param url API endpoint, defaults to http://alm.plos.org/api/v3/articles (character) 27 | #' @param ... optional additional curl options (debugging tools mostly) 28 | #' @references See a tutorial/vignette for alm at 29 | #' \url{http://ropensci.org/tutorials/alm_tutorial.html} 30 | #' @examples \dontrun{ 31 | #' alm_sources() 32 | #' alm_sources(source_id='mendeley') 33 | #' alm_sources(source_id='scopus', info='summary') 34 | #' lapply(c('mendeley','twitter'), alm_sources, limit = 2) 35 | #' alm_sources(source_id='mendeley', limit=2) 36 | #' alm_sources(source_id='mendeley', limit=2, page=2) 37 | #' alm_sources(source_id='mendeley', limit=200) 38 | #' 39 | #' alm_sources(source_id='mendeley', info='summary') 40 | #' } 41 | 42 | alm_sources <- function(source_id = 'crossref', info = "totals", key = NULL, total_details = FALSE, 43 | sum_metrics = NULL, limit=50, page=1, url = 'http://alm.plos.org/api/v5/articles', ...) 44 | { 45 | # key <- getkey(key) 46 | info <- match.arg(info, c("summary","totals","detail")) 47 | source_id <- match.arg(source_id, c("bloglines","citeulike","connotea","crossref","nature", 48 | "postgenomic","pubmed","scopus","plos","researchblogging", 49 | "biod","webofscience","pmc","facebook","mendeley","twitter", 50 | "wikipedia","scienceseeker","relativemetric","f1000","figshare")) 51 | 52 | getalm <- function() { 53 | info2 <- switch(info, totals=NULL, detail='detail', summary='summary') 54 | if(!is.null(sum_metrics)) info <- info2 <- 'detail' 55 | args <- almcompact(list(api_key = key, info = info2, source_id = source_id)) 56 | 57 | if(limit <= 50){ 58 | tt <- alm_GET(url, c(args, per_page=limit, page=page), ...) 59 | } else 60 | { 61 | pages <- 1 : (round_any(limit, 50, f = ceiling)/50) 62 | temp <- lapply(pages, function(k) alm_GET(x = url, y = c(args, page=k, per_page=50), ...)) 63 | tt <- do.call(c, lapply(temp, "[[", "data")) 64 | remove <- (length(pages)*50)-limit 65 | tt <- if(!remove==0) tt[-c(((length(tt)-remove)+1):length(tt))] else tt 66 | } 67 | 68 | if(info=="summary"){ 69 | tmpdetails <- if(limit <= 50) lapply(tt$data, get_details) else lapply(tt, get_details) 70 | tmpsposts <- if(limit <= 50) lapply(tt$data, get_signpost) else lapply(tt, get_signpost) 71 | details <- ldply(tmpdetails, data.frame) 72 | sposts <- ldply(tmpsposts, data.frame) 73 | return( list(meta=metadf(tt), details=details, signposts=sposts) ) 74 | } else { 75 | rep <- if(limit <= 50) tt$data else tt 76 | restmp <- lapply(rep, getdata, y=info, z=total_details, w=sum_metrics) 77 | restmp <- Map(function(x, y) data.frame(doi=y, x), restmp, vapply(rep, "[[", "", "doi")) 78 | restmp <- do.call(rbind, restmp) 79 | names(restmp)[2] <- "source_id" 80 | return( list(meta=metadf(tt), data=restmp) ) 81 | } 82 | } 83 | 84 | safe_getalm <- plyr::failwith(NULL, getalm) 85 | safe_getalm() 86 | } 87 | -------------------------------------------------------------------------------- /man-roxygen/alm_egs.R: -------------------------------------------------------------------------------- 1 | #' @seealso \code{\link{alm_plot}} 2 | #' @details You can only supply one of the parmeters doi, pmid, pmcid, wos, scp, or url; and you 3 | #' must supply one of them. Query for as many articles at a time as you like. Though queries 4 | #' are broken up in to smaller bits of 50 identifiers at a time. If you supply days, months and/or 5 | #' year parameters, days takes precedence over months and year. 6 | #' @return PLoS altmetrics as data.frame's. 7 | #' @examples \dontrun{ 8 | #' # The default call with either doi, pmid, pmcid, wos, scp, or url without specifying 9 | #' # an argument for info 10 | #' alm_ids(doi="10.1371/journal.pone.0029797") 11 | #' 12 | #' # Details for a single DOI 13 | #' out <- alm_ids(doi='10.1371/journal.pone.0029797', info='detail') 14 | #' out 15 | #' ## totals 16 | #' out$data$info 17 | #' ## history 18 | #' out$data$sum_metrics 19 | #' 20 | #' # A single PubMed ID (pmid) 21 | #' alm_ids(pmid=22590526) 22 | #' 23 | #' # A single PubMed Central ID (pmcid) 24 | #' alm_ids(pmcid=212692, info='summary') 25 | #' 26 | #' # A single Web of Science ID (wos) 27 | #' alm_ids(wos="000268452400005") 28 | #' 29 | #' # A single Scopus ID (scp) 30 | #' alm_ids(scp="68049122102") 31 | #' 32 | #' # A single Canonical URL (url) 33 | #' alm_ids(url="http://www.plosmedicine.org/article/info:doi/10.1371/journal.pmed.1000097") 34 | #' 35 | #' # Provide more than one DOI 36 | #' dois <- c('10.1371/journal.pone.0001543','10.1371/journal.pone.0040117', 37 | #' '10.1371/journal.pone.0029797','10.1371/journal.pone.0039395') 38 | #' out <- alm_ids(doi=dois) 39 | #' out$data[[1]] # get data for the first DOI 40 | #' 41 | #' # Search for DOI's, then feed into alm 42 | #' library('rplos') 43 | #' dois <- searchplos(q='evolution', fl='id', 44 | #' fq=list('-article_type:correction','doc_type:full'), limit = 250) 45 | #' out <- alm_ids(doi=dois$data$id) 46 | #' lapply(out, head) 47 | #' 48 | #' alm_ids(dois$data$id[1:5], source_id = "facebook") 49 | #' 50 | #' sources <- c("facebook","twitter","mendeley","reddit","scopus","wikipedia") 51 | #' lapply(sources, function(x) alm_ids(dois$data$id[1:5], source_id = x)) 52 | #' 53 | #' # Provide more than one pmid 54 | #' pmids <- c(19300479, 19390606, 19343216) 55 | #' out <- alm_ids(pmid=pmids) 56 | #' out$data[[3]] # get data for the third pmid 57 | #' 58 | #' # Getting data for a specific source_id 59 | #' alm_ids(doi='10.1371/journal.pone.0035869', source_id='mendeley') 60 | #' alm_ids(doi='10.1371/journal.pone.0035869', source_id='twitter') 61 | #' alm_ids(doi='10.1371/journal.pone.0035869', source_id='counter', info='detail') 62 | #' ## fails if more than one source_id given 63 | #' # alm_ids(doi='10.1371/journal.pone.0035869', source_id=c('twitter','facebook')) 64 | #' 65 | #' # Get detailed totals output 66 | #' alm_ids(doi='10.1371/journal.pone.0035869', total_details=TRUE) 67 | #' 68 | #' # Get summary metrics by day 69 | #' alm_ids(doi='10.1371/journal.pone.0036240', sum_metrics='day') 70 | #' 71 | #' # Get summary metrics by month 72 | #' alm_ids(doi='10.1371/journal.pone.0036240', sum_metrics='month') 73 | #' 74 | #' # Get summary metrics by year 75 | #' alm_ids(doi='10.1371/journal.pone.0036240', sum_metrics='year') 76 | #' 77 | #' # Get data by source_id 78 | #' alm_ids(source_id='crossref') 79 | #' alm_ids(source_id='twitter') 80 | #' 81 | #' # Curl debugging 82 | #' library('httr') 83 | #' alm_ids(doi="10.1371/journal.pone.0029797", config=verbose()) 84 | #' dois <- c('10.1371/journal.pone.0001543','10.1371/journal.pone.0040117', 85 | #' '10.1371/journal.pone.0029797','10.1371/journal.pone.0039395') 86 | #' alm_ids(doi=dois, config=progress()) 87 | #' 88 | #' # Data from other sources 89 | #' ## Crossref article data 90 | #' ### Pass in a different URL - no key needed 91 | #' api_url <- "http://det.labs.crossref.org/api/v5/articles" 92 | #' alm_ids(doi='10.1371/journal.pone.0086859', api_url = api_url) 93 | #' alm_ids(doi='10.11646/zootaxa.3618.1.1', api_url = api_url) 94 | #' alm_ids(doi='10.1016/j.jep.2013.06.007', api_url = api_url) 95 | #' alm_ids(doi='10.1111/j.1756-1051.2012.00099.x', api_url = api_url) 96 | #' 97 | #' ## Public Knowledge Project article data 98 | #' ### pass in a different url - an API key needed 99 | #' api_url <- 'http://pkp-alm.lib.sfu.ca/api/v5/articles' 100 | #' alm_ids(doi='10.3402/gha.v7.23554', api_url = api_url, key = getOption("pkpalmkey")) 101 | #' 102 | #' ## eLife 103 | #' ### pass in a different url - no key needed 104 | #' api_url <- 'http://lagotto.svr.elifesciences.org/api/v5/articles' 105 | #' alm_ids(doi='10.7554/eLife.00471', api_url = api_url) 106 | #' } 107 | -------------------------------------------------------------------------------- /R/zzz.R: -------------------------------------------------------------------------------- 1 | #' Concatenate author names, if present, used in other functions. 2 | #' 3 | #' @param x a single list element with PLoS API returned nested elements 4 | #' @return data.frame of results, with authors concatenated to single vector. 5 | #' @export 6 | #' @keywords internal 7 | concat_todf <- function(x){ 8 | if(inherits(x$author_display, "character")){ 9 | if(length(x$author_display) > 1){x$author_display<-paste(x$author_display, collapse=", ")} else 10 | {x$author_display<-x$author_display} 11 | data.frame(x) 12 | } else 13 | if(inherits(x$author, "character")){ 14 | if(length(x$author) > 1){x$author<-paste(x$author, collapse=", ")} else 15 | {x$author<-x$author} 16 | data.frame(x) 17 | } else 18 | data.frame(x) 19 | } 20 | 21 | #' Adds elements in a list that are missing because they were not returned 22 | #' in the PLoS API call. 23 | #' 24 | #' @importFrom plyr laply 25 | #' @param x A list with PLoS API returned nested elements 26 | #' @return A list with the missing element added with an 27 | #' "na", if it is missing. 28 | #' @export 29 | #' @keywords internal 30 | addmissing <- function(x){ 31 | names_ <- names(x[[which.max(laply(x, length))]]) 32 | 33 | bbb <- function(x){ 34 | if(identical(names_[!names_ %in% names(x)], character(0))){x} else 35 | { 36 | xx <- rep("na", length(names_[!names_ %in% names(x)])) 37 | names(xx) <- names_[!names_ %in% names(x)] 38 | c(x, xx) 39 | } 40 | } 41 | lapply(x, bbb) 42 | } 43 | 44 | #' Function to get an API key. 45 | #' 46 | #' Checks first to get key from your .Rprofile file for an API key with the name 47 | #' 'PlosApiKey'. If it is not found, the default guest key is used. 48 | #' 49 | #' @param x An API key, defaults to NULL. 50 | #' @examples \dontrun{ 51 | #' getkey() 52 | #' } 53 | #' @keywords internal 54 | #' @export 55 | getkey <- function(x = NULL) { 56 | if(is.null(x)){ 57 | key <- Sys.getenv("ALM_KEY", "") 58 | if(key == "") key <- getOption("PlosApiKey") 59 | 60 | if(is.null(key)){ 61 | key <- "rkfDr76z75benY3pytM1" 62 | message("Using default key: Please get your own API key at http://api.plos.org/") 63 | } else 64 | if(class(key)=="character"){key <- key} else 65 | { stop("check your key input - it should be a character string") } 66 | } else { 67 | key <- x 68 | } 69 | key 70 | } 71 | 72 | #' Capitalize the first letter of a character string. 73 | #' 74 | #' @param s A character string 75 | #' @param strict Should the algorithm be strict about capitalizing. Defaults to FALSE. 76 | #' @param onlyfirst Capitalize only first word, lowercase all others. Useful for 77 | #' taxonomic names. 78 | #' @examples 79 | #' alm_capwords(c("using AIC for model selection")) 80 | #' alm_capwords(c("using AIC for model selection"), strict=TRUE) 81 | #' @export 82 | #' @keywords internal 83 | alm_capwords <- function(s, strict = FALSE, onlyfirst = FALSE) { 84 | cap <- function(s) paste(toupper(substring(s,1,1)), 85 | {s <- substring(s,2); if(strict) tolower(s) else s}, sep = "", collapse = " " ) 86 | if(!onlyfirst){ 87 | sapply(strsplit(s, split = " "), cap, USE.NAMES = !is.null(names(s))) 88 | } else 89 | { 90 | sapply(s, function(x) 91 | paste(toupper(substring(x,1,1)), 92 | tolower(substring(x,2)), 93 | sep="", collapse=" "), USE.NAMES=F) 94 | } 95 | } 96 | 97 | #' Remove null elements in a list 98 | #' @param x A list 99 | #' @export 100 | #' @keywords internal 101 | almcompact <- function (x) Filter(Negate(is.null), x) 102 | 103 | #' List the possible alert classes 104 | #' @export 105 | alert_classes <- function() alert_classes_strings 106 | 107 | alert_classes_strings <- c('Net::HTTPUnauthorized','Net::HTTPRequestTimeOut','Delayed::WorkerTimeout','DelayedJobError','Net::HTTPConflict','Net::HTTPServiceUnavailable','Faraday::ResourceNotFound','ActiveRecord::RecordInvalid','TooManyErrorsBySourceError','SourceInactiveError','TooManyWorkersError','EventCountDecreasingError','EventCountIncreasingTooFastError','ApiResponseTooSlowError','HtmlRatioTooHighError','ArticleNotUpdatedError','SourceNotUpdatedError','CitationMilestoneAlert') 108 | 109 | alm_GET <- function(x, y, sleep=0, ...){ 110 | Sys.sleep(time = sleep) 111 | out <- GET(x, query=y, ...) 112 | stop_for_status(out) 113 | tt <- content(out, as = "text") 114 | jsonlite::fromJSON(tt, FALSE) 115 | } 116 | 117 | alm_POST <- function(x, y, sleep=0, ...){ 118 | Sys.sleep(time = sleep) 119 | out <- POST(x, body=y, add_headers("X-HTTP-Method-Override" = "GET"), ...) 120 | stop_for_status(out) 121 | tt <- content(out, as = "text") 122 | jsonlite::fromJSON(tt, FALSE) 123 | } 124 | -------------------------------------------------------------------------------- /man/alm_events.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.1.0): do not edit by hand 2 | % Please edit documentation in R/alm_events.R 3 | \name{alm_events} 4 | \alias{alm_events} 5 | \title{Retrieve PLoS article-level metrics (ALM) events.} 6 | \usage{ 7 | alm_events(doi = NULL, pmid = NULL, pmcid = NULL, wos = NULL, 8 | scp = NULL, url = NULL, source_id = NULL, publisher_id = NULL, 9 | compact = TRUE, key = NULL, 10 | api_url = "http://alm.plos.org/api/v5/articles", ...) 11 | } 12 | \arguments{ 13 | \item{doi}{Digital object identifier for an article in PLoS Journals (character)} 14 | 15 | \item{pmid}{PubMed object identifier (numeric)} 16 | 17 | \item{pmcid}{PubMed Central object identifier (numeric)} 18 | 19 | \item{wos}{Web of Science identifier (character)} 20 | 21 | \item{scp}{Scopus identifier (character)} 22 | 23 | \item{url}{Canonical URL (character)} 24 | 25 | \item{source_id}{(character) Name of source to get ALM information for. One source only. 26 | You can get multiple sources via a for loop or lapply-type call.} 27 | 28 | \item{publisher_id}{(character) Metrics for articles by a given publisher, using the Crossref 29 | \code{member_id}.} 30 | 31 | \item{compact}{(logical) Whether to make output compact or not. If TRUE (default), remove 32 | empty sources.} 33 | 34 | \item{key}{(character) Your API key, either enter, or loads from .Rprofile. Only required for 35 | PKP source, not the others.} 36 | 37 | \item{api_url}{API endpoint, defaults to http://alm.plos.org/api/v3/articles (character)} 38 | 39 | \item{...}{optional additional curl options (debugging tools mostly)} 40 | } 41 | \value{ 42 | PLoS altmetrics as data.frame's. 43 | } 44 | \description{ 45 | Events are the details of the metrics that are counted related to PLoS papers. 46 | } 47 | \details{ 48 | You can only supply one of the parmeters doi, pmid, pmcid, and mendeley. 49 | 50 | Query for as many articles at a time as you like. Though queries are broken 51 | up in to smaller bits of 30 identifiers at a time. 52 | 53 | If you supply both the days and months parameters, days takes precedence, 54 | and months is ignored. 55 | 56 | You can get events from many different sources. After calling alm_events, 57 | then index the output by the data provider you want. The options are: 58 | bloglines, citeulike, connotea, crossref, nature, postgenomic, pubmed, 59 | scopus, plos, researchblogging, biod, webofscience, pmc, facebook, 60 | mendeley, twitter, wikipedia, and scienceseeker. 61 | 62 | Beware that some data source are not parsed yet, so there may be event data 63 | but it is not provided yet as it is so messy to parse. 64 | 65 | See more info on PLOS's relative metrics event source here 66 | \url{http://www.plosone.org/static/almInfo#relativeMetrics} 67 | } 68 | \examples{ 69 | \dontrun{ 70 | # For one article 71 | out <- alm_events(doi="10.1371/journal.pone.0029797") 72 | names(out) # names of sources 73 | # remove those with no data 74 | out <- out[!out \%in\% c("sorry, no events content yet","parser not written yet")] 75 | out[["pmc"]] # get the results for PubMed Central 76 | out[["twitter"]] # get the results for twitter 77 | out[["plos_comments"]] # get the results for PLOS comments, sorta messy 78 | out[c("twitter","crossref")] # get the results for two sources 79 | 80 | # Another example 81 | (out <- alm_events(doi="10.1371/journal.pone.0001543")) 82 | # remove those with no data 83 | out <- out[!out \%in\% c("sorry, no events content yet","parser not written yet")] 84 | names(out) 85 | out[['scopus']] 86 | out[['mendeley']] 87 | out[['figshare']] 88 | out[['pubmed']] 89 | 90 | # Two doi's 91 | dois <- c('10.1371/journal.pone.0001543','10.1371/journal.pone.0040117') 92 | out <- alm_events(doi=dois) 93 | out[[1]] 94 | out[[2]] 95 | out[[1]][["figshare"]]$events 96 | 97 | # Many pmcid's 98 | out <- alm_events(pmcid=c(212692,2082661)) 99 | names(out) 100 | out['212692'] 101 | 102 | # Many pmid's 103 | out <- alm_events(pmid = c(19300479, 19390606, 19343216)) 104 | names(out) 105 | out['19390606'] 106 | 107 | # Specify two specific sources 108 | ## You have to do so through lapply, or similar approach 109 | lapply(c("crossref","twitter"), 110 | function(x) alm_events(doi="10.1371/journal.pone.0035869", source_id=x)) 111 | 112 | # Figshare data 113 | alm_events(doi="10.1371/journal.pone.0069841", source_id='figshare') 114 | 115 | # Datacite data 116 | alm_events("10.1371/journal.pone.0012090", source_id='datacite') 117 | 118 | # Reddit data 119 | alm_events("10.1371/journal.pone.0015552", source_id='reddit') 120 | 121 | # Wordpress data 122 | alm_events("10.1371/journal.pcbi.1000361", source_id='wordpress') 123 | 124 | # Articlecoverage data 125 | alm_events(doi="10.1371/journal.pmed.0020124", source_id='articlecoverage') 126 | 127 | # Articlecoveragecurated data 128 | headfoo <- function(x) head(x$articlecoveragecurated$events) 129 | headfoo(alm_events(doi="10.1371/journal.pone.0088278", source_id='articlecoveragecurated')) 130 | headfoo(alm_events(doi="10.1371/journal.pmed.1001587", source_id='articlecoveragecurated')) 131 | 132 | # F1000 Prime data 133 | alm_events(doi="10.1371/journal.pbio.1001041", source_id='f1000') 134 | dois <- c('10.1371/journal.pmed.0020124','10.1371/journal.pbio.1001041', 135 | '10.1371/journal.pbio.0040020') 136 | res <- alm_events(doi = dois, source_id='f1000') 137 | res[[3]] 138 | 139 | # by source_id only 140 | alm_events(source_id = "crossref") 141 | alm_events(source_id = "reddit") 142 | 143 | # by publisher_id only 144 | alm_events(publisher_id = 340) 145 | 146 | # search the software lagotto sever 147 | urls <- c("https://github.com/najoshi/sickle","https://github.com/lh3/wgsim", 148 | "https://github.com/jstjohn/SeqPrep") 149 | dat <- alm_events(url = urls, api_url = "http://software.lagotto.io/api/v5/articles") 150 | } 151 | } 152 | \references{ 153 | See a tutorial/vignette for alm at 154 | \url{http://ropensci.org/tutorials/alm_tutorial.html} 155 | } 156 | 157 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | alm 0.4.1 2 | ========= 3 | 4 | NEW FEATURES 5 | 6 | * Archived on CRAN. 7 | 8 | alm 0.4.0 9 | =============== 10 | 11 | NEW FEATURES 12 | 13 | * API keys no longer needed for the most part, though some data providers that use Lagotto 14 | run older versions of Lagotto that require API keys. (#43) 15 | * New function `alm_requests()` to get metadata on the API requests sent to a Lagotto instance. 16 | Note that this function requires authentication, and a certain level of access. (#37) 17 | * Some functions gained new parameters: `wos` for a Web of Science identifier, and `scp` for 18 | a Scopus identifier 19 | * `alm_ids()` and `alm_events()` now use `POST` requests by default to allow larger data 20 | requests. 21 | 22 | MINOR IMPROVEMENTS 23 | 24 | * Throughout functions, `source` parameter has changed to `source_id`, and `publisher` to 25 | `publisher_id` (#40) 26 | * Throughout functions, `url` parameter has changed to `api_url`. The parameter `url` is now 27 | the URL for an object, e.g., a GitHub repository. 28 | * Throughout functions, `rows` parameter changed to `per_page` 29 | * The parameter `mendeley_uuid` removed. 30 | * `alm_plot()` changed so that it only has one type of output. 31 | * `type` parameter dropped from the `plot_signposts()` function so that we don't have to import 32 | the `rCharts` package, which is not on CRAN. 33 | * Various improvements to the vignette 34 | 35 | BUG FIXES 36 | 37 | * Fixed Mendeley event parser in `alm_events()` (#45) 38 | * `rCharts` removed from package (#42) 39 | 40 | alm 0.3.1 41 | =============== 42 | 43 | MINOR IMPROVEMENTS 44 | 45 | * Vignette now as markdown (renders as HTML) instead of as pdf. 46 | 47 | BUG FIXES 48 | 49 | * Fixed two broken tests. 50 | * Made `REAMDE` WC3 compliant on Kurt Hornik's request. (#21) 51 | * Fixed bad parsing for `researchblogging` source in `alm_events()` (#35). 52 | 53 | alm 0.3.0 54 | =============== 55 | 56 | NEW FEATURES 57 | 58 | * The ALM service that this package interacts with was recently renamed to Lagotto. 59 | * New function `alm_alerts()` added. This function works only with the v4 API, and you have to be given certain status in the Lagotto server to be able to use this function, which requires your username and API key. 60 | * Using `jsonlite` now instead of `RJSONIO` for JSON parsing. 61 | * Now using `httr` instead of `RCurl`. 62 | * Along with using `httr` instead of `RCurl`, all functions now accept options via the `...` parameter that are passed on to `httr::GET()`. 63 | * New function `alm_signposts()` that uses `alm_ids()` internally, and just gives back the viewed, saved, discussed, and cited summary data. 64 | * New function `alm_status()` to check status of the Lagotto server for any publisher using the service. (#24) 65 | * New function `alm_sources()` to search for data based on source type, e,g., Twitter. 66 | * The `source` parameter only takes one source type now. This is a rather large change. You can still seaerch for multiple sources, just pass them through the function via a for loop or `lapply` type function. 67 | * This version of the package now is set up to deal with the Lagotto version 5 API. Thus, the default URL for the PLOS server is `http://alm.plos.org/api/v5/articles`, and similar for other publishers. 68 | * `alm_events()` now by default drops all sources with no data, toggle this with the `compact` parameter (#26) 69 | 70 | MINOR IMPROVEMENTS 71 | 72 | * Changed license to `MIT` from `CC0`. 73 | * A series of functions now defunct: `alm_pubmedid()`, `alm_pubmedcentid()`, `almupdated()`, `almdateupdated()`, `alm_totals()`. The functionality of all of these functions can be done with `alm_ids()`. 74 | * `alm()` function name changed to `alm_ids()` to avoid confusion with the package name. 75 | * `almdatepub()` function name changed to `alm_datepub()` to be consistent with snake_case naming of other functions. 76 | * `almtitle()` function name changed to `alm_title()` to be consistent with snake_case naming of other functions. Also, message added to say this function will be gone soon. 77 | * `almplot()` function name changed to `alm_plot()` to be consistent with snake_case naming of other functions. 78 | * `almevents()` function name changed to `alm_events()` to be consistent with snake_case naming of other functions. 79 | * Parameter `mdid` across function changed to `mendeley_uuid` - for the Mendeley UUID. 80 | * Options for parameter `info` changed to totals, summary, or detail - history option deprecated. 81 | * `months`, `days`, and `year` parameter gone. 82 | * `signposts()` function name change to `alm_signposts()` 83 | 84 | alm 0.1.9 85 | =============== 86 | 87 | BUG FIXES 88 | 89 | * Fixed some broken tests 90 | 91 | MINOR IMPROVEMENTS 92 | 93 | * Added additional exmple to `almevents()` to get data from the eLife ALM API server 94 | 95 | 96 | alm 0.1.8 97 | =============== 98 | 99 | BUG FIXES 100 | 101 | * Fixed bug in `almevents()` that was causing the function to fail - due to change in the webservices (#18) 102 | 103 | MINOR IMPROVEMENTS 104 | 105 | * Tidied code a bit and fixed parsing in a few sources in `almevents()`. 106 | * Added more examples in `almevents()` for using CrossRef, PKP, and Copernicus. 107 | 108 | alm 0.1.6 109 | =============== 110 | 111 | BUG FIXES 112 | 113 | * Fixed a few tests that were failing due to changes in the PLOS ALM API. 114 | 115 | alm 0.1.4 116 | =============== 117 | 118 | MINOR IMPROVEMENTS 119 | 120 | * Put a note about where to get rCharts from Github in DESCIPTION file (#16) 121 | * Updated vignette with example using Crossref article level metrics API. 122 | * Updating to using new roxygen2 version. 123 | * Parsing added for new sources: datacite, copernicus, articlecoverage, and articlecoveragecurated (#13) - more parsing needs to be added for event sources, will be added soon. 124 | 125 | alm 0.1.2 126 | =============== 127 | 128 | MINOR IMPROVEMENTS 129 | 130 | * Added mdid's for PLOS articles, so searching for mdid's with alm() or almevents() works now. 131 | * Added basic handler for new sources in alm: datacite, Copernicus, ariclecoverge, and ariclecovergeupdated. 132 | * Collate removed from DESCRIPTION tile. 133 | 134 | alm 0.1.1 135 | =============== 136 | 137 | MINOR IMPROVEMENTS 138 | 139 | * Vignette changed to a link to the vignette on the web, and the file moved to vignettes/ dir from inst/doc dir. 140 | * Added parsers for F1000, Figshare, and Wordpress events data in almevents(). Note that the parsing for Figshare just returns the raw data in list format - there is a lot of text/paragraphs, so it didn't make sense to return as as data.frame. 141 | * Added link to online tutorial to most function docs. 142 | 143 | alm 0.1 144 | =============== 145 | 146 | NEW FEATURES 147 | 148 | * Released to CRAN 149 | -------------------------------------------------------------------------------- /R/plot_density.R: -------------------------------------------------------------------------------- 1 | #' Density and histogram plots from PLOS Article Level Metrics data 2 | #' 3 | #' @import ggplot2 4 | #' @importFrom grid unit grid.text gpar viewport grid.newpage 5 | #' @importFrom reshape2 melt 6 | #' @importFrom plyr round_any 7 | #' @importFrom lubridate year 8 | #' @export 9 | #' 10 | #' @param input A data.frame, usuaally from a call to \code{link{alm}}. 11 | #' @param source Data source (column) to plot. Can be a single element, or a 12 | #' character vector. 13 | #' @param color Color of the density plot and the title. Can be a hex color or 14 | #' rgb, etc. 15 | #' @param title Title for the plot, in top matching the color of the density plot. 16 | #' @param description Optional description, subtending the title. 17 | #' @param plot_type Type of plot, one of density (default) or histogram. 18 | #' @author Martin Fenner, mfenner@@plos.org, modified by Scott Chamberlain 19 | #' @references See a tutorial/vignette for alm at 20 | #' \url{http://ropensci.org/tutorials/alm_tutorial.html} 21 | #' @examples \dontrun{ 22 | #' library('rplos'); library('plyr') 23 | #' dois <- searchplos(q='*:*', fl="id", 24 | #' fq=list( 25 | #' 'cross_published_journal_key:PLoSONE', 26 | #' 'doc_type:full', 27 | #' 'publication_date:[2010-01-01T00:00:00Z TO 2010-12-31T23:59:59Z]', 28 | #' '-article_type:correction'), 29 | #' limit=50) 30 | #' dois <- dois$data$id[!grepl("annotation", dois$data$id)] 31 | #' alm <- alm_ids(doi=dois, total_details=TRUE) 32 | #' alm <- ldply(alm$data, data.frame) 33 | #' plot_density(alm) 34 | #' plot_density(alm, color="#DCA121") 35 | #' plot_density(alm, title="Scopus citations from 2010") 36 | #' plot_density(alm, title="Scopus citations from 2010", description="Probablity of 37 | #' X number of citations for a paper") 38 | #' plot_density(alm, description="Probablity of X number of citations for a paper") 39 | #' plot_density(alm, source="crossref_total") 40 | #' plot_density(alm, source="twitter_total") 41 | #' plot_density(alm, source="counter_total") 42 | #' plot_density(alm, source=c("counter_total","facebook_likes")) 43 | #' plot_density(alm, source=c("counter_total","facebook_likes")) 44 | #' plot_density(alm, source=c("counter_total","facebook_likes", "twitter_total")) 45 | #' plot_density(alm, source=c("counter_total","crossref_total","twitter_total"), 46 | #' color=c("#DBAC6A", "#E09B33", "#A06D34")) 47 | #' plot_density(alm, source=c("counter_total","crossref_total", 48 | #' "twitter_total")) 49 | #' plot_density(alm, source=c("counter_total","crossref_total"), 50 | #' title="Counter and Crossref") 51 | #' plot_density(alm, source=c("counter_total","crossref_total", 52 | #' "twitter_total"), color=c("#83DFB4","#EFA5A5","#CFD470")) 53 | #' } 54 | 55 | 56 | plot_density <- function(input, source="scopus_total", color="#1447f2", title = "", 57 | description = "", plot_type="density") { 58 | 59 | plos_color <- "#1447f2" 60 | input$date_modified <- as.Date(input$date_modified) 61 | plot_type <- match.arg(plot_type, choices=c("histogram","density")) 62 | yvarname <- switch(plot_type, 63 | histogram = "No. of articles", 64 | density = "Probability") 65 | plot_type <- switch(plot_type, 66 | histogram = "geom_histogram", 67 | density = "geom_density") 68 | 69 | # Calculate quantiles and min/max x-axis limits 70 | minmax <- c(0, round_any(max(input[,source]), 10, f=ceiling)) 71 | 72 | # Determine margin at top of plot 73 | if(nchar(title)==0 && nchar(description)!=0 | nchar(description)==0 && nchar(title)!=0){ 74 | plot_margin <- 2 75 | } else if(nchar(description)!=0 && nchar(title)!=0){ 76 | plot_margin <- 4 77 | } else if(nchar(description)==0 && nchar(title)==0){ 78 | plot_margin <- 1 79 | } 80 | 81 | theme_density <- function(){ 82 | list(theme_bw(base_size=16), 83 | theme(panel.grid.major=element_blank(), 84 | panel.grid.minor=element_blank(), 85 | panel.border=element_blank(), 86 | axis.line = element_line(color = 'black'), 87 | plot.title = element_text(colour=plos_color, size=24, hjust=0), 88 | plot.margin = unit(c(plot_margin,1,1,1), "cm")), 89 | labs(x="", y="")) 90 | } 91 | # Plot 92 | if(length(source)==1){ 93 | plos_xlab <- alm_capwords(gsub("_"," ",source)) 94 | p <- ggplot(input, aes_string(x=source)) + 95 | theme_density() + 96 | eval(parse(text=plot_type))(fill=color, colour=color) + 97 | scale_x_continuous(limits=minmax) 98 | grid.newpage() 99 | print(p, vp = viewport(width = 1, height = 1)) 100 | grid.text(yvarname, x=0.03, y=0.5, rot=90, gp=gpar(cex=1, col=plos_color)) 101 | grid.text(plos_xlab, x=0.5, y=0.04, gp=gpar(cex=1, col=plos_color)) 102 | if(nchar(title)==0 & nchar(description)!=0){ 103 | grid.text(paste(strwrap(description,width=90), collapse="\n"), x=0.1, y=0.95, just="left", gp=gpar(cex=1)) 104 | } else if(nchar(description)==0 & nchar(title)!=0){ 105 | grid.text(title, x=0.1, y=0.95, just="left", gp=gpar(cex=2, col=plos_color)) 106 | } else if(nchar(description)!=0 & nchar(title)!=0){ 107 | grid.text(title, x=0.1, y=0.95, just="left", gp=gpar(cex=2, col=plos_color)) 108 | grid.text(paste(strwrap(description,width=90), collapse="\n"), x=0.1, y=0.87, just="left", gp=gpar(cex=1)) 109 | } 110 | } else 111 | { 112 | if(length(color)==1){ 113 | colors <- rep(color,length(source)) 114 | } else 115 | { 116 | colors <- color 117 | } 118 | df <- input[,source] 119 | dfm <- melt(df) 120 | p <- ggplot(dfm, aes(x=value, fill=variable, colour=variable)) + 121 | theme_density() + 122 | eval(parse(text=plot_type))() + 123 | theme(legend.position="none") + 124 | facet_wrap(~variable, scales="free") + 125 | scale_colour_manual(values = colors) + 126 | scale_fill_manual(values = colors) 127 | grid.newpage() 128 | print(p, vp = viewport(width = 1, height = 1)) 129 | grid.text(yvarname, x=0.03, y=0.5, rot=90, gp=gpar(cex=1)) 130 | # grid.text("Count", x=0.5, y=0.04, gp=gpar(cex=1)) 131 | if(nchar(title)==0 & nchar(description)!=0){ 132 | grid.text(paste(strwrap(description,width=90), collapse="\n"), x=0.1, y=0.95, just="left", gp=gpar(cex=1)) 133 | } else if(nchar(description)==0 & nchar(title)!=0){ 134 | grid.text(title, x=0.1, y=0.95, just="left", gp=gpar(cex=2)) 135 | } else if(nchar(description)!=0 & nchar(title)!=0){ 136 | grid.text(title, x=0.1, y=0.95, just="left", gp=gpar(cex=2)) 137 | grid.text(paste(strwrap(description,width=90), collapse="\n"), x=0.1, y=0.87, just="left", gp=gpar(cex=1)) 138 | } 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /R/alm_ids.R: -------------------------------------------------------------------------------- 1 | #' Retrieve PLoS article-level metrics (ALM). 2 | #' 3 | #' This is the main function to search the PLoS ALM (article-level metrics) API. 4 | #' See details for more information. 5 | #' 6 | #' @importFrom stringr str_replace_all str_split 7 | #' @export 8 | #' @template alm_params 9 | #' @template alm_egs 10 | #' @param sleep Set a sleep time (in seconds). Only used for large calls where you may be in danger 11 | #' of upsetting the server gods, can you say 504 error? 12 | #' @references See a tutorial/vignette for alm at 13 | #' \url{http://ropensci.org/tutorials/alm_tutorial.html} 14 | 15 | alm_ids <- function(doi = NULL, pmid = NULL, pmcid = NULL, wos = NULL, scp = NULL, url = NULL, info = "totals", 16 | source_id = NULL, publisher_id = NULL, key = NULL, total_details = FALSE, sum_metrics = NULL, sleep = 0, 17 | api_url = 'http://alm.plos.org/api/v5/articles', ...){ 18 | 19 | info <- match.arg(info, c("summary","totals","detail")) 20 | if(!is.null(doi)) doi <- doi[!grepl("image", doi)] # remove any DOIs of images 21 | id <- almcompact(list(doi=doi, pmid=pmid, pmcid=pmcid, wos=wos, scp=scp, url=url, source_id=source_id, publisher_id=publisher_id)) 22 | if(length(id) == 0) stop("Supply one of: doi, pmid, pmcid, wos, scp, url, source_id, or publisher_id") 23 | if(length(delsp(id)) > 1) stop("Only supply one of: doi, pmid, pmcid, wos, scp, url") 24 | if(length(source_id) > 1) stop("You can only supply one source_id") 25 | if(length(publisher_id) > 1) stop("You can only supply one publisher_id") 26 | 27 | getalm <- function() { 28 | info2 <- switch(info, totals=NULL, detail='detail', summary='summary') 29 | if(!is.null(sum_metrics)) info <- info2 <- 'detail' 30 | args <- almcompact(list(api_key = key, info = info2, source_id = source_id, publisher_id = publisher_id, type = idtype(names(id)))) 31 | if(length(almcompact(list(doi=doi, pmid=pmid, pmcid=pmcid, wos=wos, scp=scp, url=url))) == 0){ 32 | if(length(id) == 0) stop("Please provide one of: doi, pmid, pmcid, wos, scp, url, source_id, or publisher_id") 33 | tt <- alm_GET(api_url, args, ...) 34 | } else { 35 | if(length(delsp(id)[[1]]) == 1){ 36 | passid <- if(names(delsp(id)) == "doi") gsub("/", "%2F", delsp(id)) else delsp(id) 37 | tt <- alm_GET(x = api_url, y = c(args, ids = passid[[1]]), ...) 38 | } else { 39 | if(length(delsp(id)[[1]]) > 1){ 40 | if(length(delsp(id)[[1]]) > 50){ 41 | slice <- function(x, n) split(x, as.integer((seq_along(x) - 1) / n)) 42 | idsplit <- slice(delsp(id)[[1]], 50) 43 | repeatit <- function(y) { 44 | if(names(delsp(id)) == "doi"){ 45 | id2 <- paste(sapply(y, function(x) gsub("/", "%2F", x)), collapse=",") 46 | } else { 47 | id2 <- paste(delsp(id)[[1]], collapse=",") 48 | } 49 | tt <- alm_POST(api_url, c(args, ids = id2), sleep=sleep, ...) 50 | } 51 | temp <- lapply(idsplit, repeatit) 52 | justdat <- do.call(c, unname(lapply(temp, "[[", "data"))) 53 | tt <- c(temp[[1]][ !names(temp[[1]]) == "data" ], data=list(justdat)) 54 | } else { 55 | id2 <- id2 <- concat_ids(delsp(id)) 56 | tt <- alm_POST(api_url, c(args, ids = id2), ...) 57 | } 58 | } 59 | } 60 | } 61 | 62 | if(info=="summary"){ 63 | if(length(id[[1]]) > 1 | !is.null(source_id) | !is.null(publisher_id)){ 64 | restmp <- lapply(tt$data, getsummary) 65 | names(restmp) <- vapply(tt$data, doiorid, character(1)) 66 | } else { 67 | restmp <- getsummary(tt$data[[1]]) 68 | } 69 | list(meta=metadf(tt), data=restmp) 70 | } else { 71 | if(length(id[[1]]) > 1 | !is.null(source_id) | !is.null(publisher_id)){ 72 | restmp <- lapply(tt$data, getdata, y=info, z=total_details, w=sum_metrics) 73 | names(restmp) <- vapply(tt$data, doiorid, character(1)) 74 | } else { 75 | checktt <- tryCatch(tt$data[[1]], error=function(e) e) 76 | restmp <- if(is(checktt, "simpleError")) list() else getdata(x=tt$data[[1]], y=info, z=total_details, w=sum_metrics) 77 | } 78 | return( list(meta=metadf(tt), data=restmp) ) 79 | } 80 | } 81 | 82 | safe_getalm <- plyr::failwith(NULL, getalm) 83 | safe_getalm() 84 | } 85 | 86 | doiorid <- function(x) { 87 | if(is.null(x$doi)) { 88 | x$id 89 | } else { 90 | x$doi 91 | } 92 | } 93 | 94 | concat_ids <- function(x){ 95 | if(names(x) == "doi") { 96 | paste(sapply(x, function(y) gsub("/", "%2F", y)), collapse=",") 97 | } else { paste(x[[1]], collapse=",") } 98 | } 99 | 100 | getdata <- function(x, y, z=FALSE, w=NULL) { 101 | if(y == "totals"){ 102 | get_totals(x, z) 103 | } else { 104 | if(is.null(w)){ 105 | tots <- get_totals(x, z) 106 | summets <- get_sumby(x$sources, w) 107 | list(info=get_details(x), 108 | signposts=get_signpost(x), 109 | totals=tots, 110 | sum_metrics=summets) 111 | } else { 112 | get_sumby(x$sources, w) 113 | } 114 | } 115 | } 116 | 117 | getsummary <- function(x) { 118 | list(info=get_details(x), 119 | signposts=get_signpost(x)) 120 | } 121 | 122 | metadf <- function(x){ 123 | tmp <- x[!names(x) == 'data'] 124 | tmp[vapply(tmp, is.null, logical(1))] <- NA 125 | data.frame(tmp, stringsAsFactors = FALSE) 126 | } 127 | 128 | get_totals <- function(x, total_details=FALSE){ 129 | servs <- sapply(x$sources, function(x) x$name) 130 | totals <- lapply(x$sources, function(x) x$metrics) 131 | totals2 <- lapply(totals, function(x){ 132 | x[sapply(x, is.null)] <- NA 133 | x 134 | }) 135 | names(totals2) <- servs 136 | 137 | if(total_details){ 138 | temp <- data.frame(t(unlist(totals2, use.names=TRUE))) 139 | names(temp) <- str_replace_all(names(temp), "\\.", "_") 140 | cbind(data.frame( 141 | id=x$id, 142 | title=x$title), 143 | temp, date_modified=x$update_date) 144 | } else { ldply(totals2, function(x) as.data.frame(x)) } 145 | } 146 | 147 | get_details <- function(x){ 148 | date_parts <- x$issued$`date-parts`[[1]] 149 | date_parts[[2]] <- if(nchar(date_parts[[2]]) == 1) paste0("0", date_parts[[2]]) else date_parts[[2]] 150 | date_parts <- paste(date_parts, collapse = "-") 151 | tmp <- x[ !names(x) %in% c('sources','issued','viewed','saved','discussed','cited') ] 152 | tmp[sapply(tmp, is.null)] <- "" 153 | data.frame(tmp, issued=date_parts, stringsAsFactors = FALSE) 154 | } 155 | 156 | get_signpost <- function(x){ 157 | tmp <- x[ names(x) %in% c('id','viewed','saved','discussed','cited') ] 158 | tmp[vapply(tmp, is.null, logical(1))] <- NA 159 | data.frame(tmp, stringsAsFactors = FALSE) 160 | } 161 | 162 | get_sumby <- function(x, y){ 163 | sumby <- paste0("by_", match.arg(y, choices=c("day","month","year"))) 164 | servs <- sapply(x, function(z) z$name) 165 | totals <- lapply(x, function(z) z[[sumby]]) 166 | totals[sapply(totals,is.null)] <- NA 167 | totals2 <- lapply(totals, function(z){ 168 | z <- lapply(z, function(w) { w[sapply(w, is.null)] <- NA; w }) 169 | z 170 | }) 171 | names(totals2) <- servs 172 | tmp <- ldply(totals2, function(v) ldply(v, as.data.frame)) 173 | if(NROW(tmp) == 0) NULL else tmp 174 | } 175 | -------------------------------------------------------------------------------- /man/alm_ids.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.1.0): do not edit by hand 2 | % Please edit documentation in R/alm_ids.R 3 | \name{alm_ids} 4 | \alias{alm_ids} 5 | \title{Retrieve PLoS article-level metrics (ALM).} 6 | \usage{ 7 | alm_ids(doi = NULL, pmid = NULL, pmcid = NULL, wos = NULL, scp = NULL, 8 | url = NULL, info = "totals", source_id = NULL, publisher_id = NULL, 9 | key = NULL, total_details = FALSE, sum_metrics = NULL, sleep = 0, 10 | api_url = "http://alm.plos.org/api/v5/articles", ...) 11 | } 12 | \arguments{ 13 | \item{doi}{(character) Digital object identifier for an article in PLoS Journals} 14 | 15 | \item{pmid}{(numeric) PubMed object identifier} 16 | 17 | \item{pmcid}{(numeric) PubMed Central object identifier} 18 | 19 | \item{wos}{(character) Web of Science identifier} 20 | 21 | \item{scp}{(character) Scopus identifier} 22 | 23 | \item{url}{(character) Canonical URL. This is a URL for an object, not the URL for the 24 | Lagotto instance (see api_url)} 25 | 26 | \item{info}{One of totals, summary, or detail (default totals + sum_metrics data in a list). 27 | Not specifying anything (the default) returns data.frame of totals across 28 | data providers. (character). \code{info='detail'} returns all possible data, including slots 29 | for info, signposts, totals, and sum_metrics (see the sum_metrics parameter below). 30 | IMPORTANT: note, however, that you can only get by day metrics for articles published since 31 | May 2014.} 32 | 33 | \item{source_id}{(character) Name of source to get ALM information for. One source only. 34 | You can get multiple sources via a for loop or lapply-type call.} 35 | 36 | \item{publisher_id}{(character) Metrics for articles by a given publisher, using the Crossref 37 | \code{member_id}.} 38 | 39 | \item{key}{(character) Your API key, either enter, or loads from .Rprofile. Only required for 40 | PKP source, not the others.} 41 | 42 | \item{total_details}{(logical) If FALSE (the default) the standard totals data.frame is 43 | returned; if TRUE, the totals data is in a wide format with more details 44 | about the paper, including publication date, title, etc. If you set this 45 | to TRUE, the output should no longer with with \code{\link{alm_plot}}.} 46 | 47 | \item{sum_metrics}{(character) Just like the output you get from setting info='totals', you can 48 | get summary metrics by day (sum_metrics='day'), month (sum_metrics='month'), 49 | or year (sum_metrics='year'). IMPORTANT: note that you can only get by day metrics for 50 | articles published since May 2014.} 51 | 52 | \item{sleep}{Set a sleep time (in seconds). Only used for large calls where you may be in danger 53 | of upsetting the server gods, can you say 504 error?} 54 | 55 | \item{api_url}{(character) API endpoint, defaults to http://alm.plos.org/api/v5/articles} 56 | 57 | \item{...}{Curl options (debugging tools mostly) passed on to \code{\link[httr]{GET}}} 58 | } 59 | \value{ 60 | PLoS altmetrics as data.frame's. 61 | } 62 | \description{ 63 | This is the main function to search the PLoS ALM (article-level metrics) API. 64 | See details for more information. 65 | } 66 | \details{ 67 | You can only supply one of the parmeters doi, pmid, pmcid, wos, scp, or url; and you 68 | must supply one of them. Query for as many articles at a time as you like. Though queries 69 | are broken up in to smaller bits of 50 identifiers at a time. If you supply days, months and/or 70 | year parameters, days takes precedence over months and year. 71 | } 72 | \examples{ 73 | \dontrun{ 74 | # The default call with either doi, pmid, pmcid, wos, scp, or url without specifying 75 | # an argument for info 76 | alm_ids(doi="10.1371/journal.pone.0029797") 77 | 78 | # Details for a single DOI 79 | out <- alm_ids(doi='10.1371/journal.pone.0029797', info='detail') 80 | out 81 | ## totals 82 | out$data$info 83 | ## history 84 | out$data$sum_metrics 85 | 86 | # A single PubMed ID (pmid) 87 | alm_ids(pmid=22590526) 88 | 89 | # A single PubMed Central ID (pmcid) 90 | alm_ids(pmcid=212692, info='summary') 91 | 92 | # A single Web of Science ID (wos) 93 | alm_ids(wos="000268452400005") 94 | 95 | # A single Scopus ID (scp) 96 | alm_ids(scp="68049122102") 97 | 98 | # A single Canonical URL (url) 99 | alm_ids(url="http://www.plosmedicine.org/article/info:doi/10.1371/journal.pmed.1000097") 100 | 101 | # Provide more than one DOI 102 | dois <- c('10.1371/journal.pone.0001543','10.1371/journal.pone.0040117', 103 | '10.1371/journal.pone.0029797','10.1371/journal.pone.0039395') 104 | out <- alm_ids(doi=dois) 105 | out$data[[1]] # get data for the first DOI 106 | 107 | # Search for DOI's, then feed into alm 108 | library('rplos') 109 | dois <- searchplos(q='evolution', fl='id', 110 | fq=list('-article_type:correction','doc_type:full'), limit = 250) 111 | out <- alm_ids(doi=dois$data$id) 112 | lapply(out, head) 113 | 114 | alm_ids(dois$data$id[1:5], source_id = "facebook") 115 | 116 | sources <- c("facebook","twitter","mendeley","reddit","scopus","wikipedia") 117 | lapply(sources, function(x) alm_ids(dois$data$id[1:5], source_id = x)) 118 | 119 | # Provide more than one pmid 120 | pmids <- c(19300479, 19390606, 19343216) 121 | out <- alm_ids(pmid=pmids) 122 | out$data[[3]] # get data for the third pmid 123 | 124 | # Getting data for a specific source_id 125 | alm_ids(doi='10.1371/journal.pone.0035869', source_id='mendeley') 126 | alm_ids(doi='10.1371/journal.pone.0035869', source_id='twitter') 127 | alm_ids(doi='10.1371/journal.pone.0035869', source_id='counter', info='detail') 128 | ## fails if more than one source_id given 129 | # alm_ids(doi='10.1371/journal.pone.0035869', source_id=c('twitter','facebook')) 130 | 131 | # Get detailed totals output 132 | alm_ids(doi='10.1371/journal.pone.0035869', total_details=TRUE) 133 | 134 | # Get summary metrics by day 135 | alm_ids(doi='10.1371/journal.pone.0036240', sum_metrics='day') 136 | 137 | # Get summary metrics by month 138 | alm_ids(doi='10.1371/journal.pone.0036240', sum_metrics='month') 139 | 140 | # Get summary metrics by year 141 | alm_ids(doi='10.1371/journal.pone.0036240', sum_metrics='year') 142 | 143 | # Get data by source_id 144 | alm_ids(source_id='crossref') 145 | alm_ids(source_id='twitter') 146 | 147 | # Curl debugging 148 | library('httr') 149 | alm_ids(doi="10.1371/journal.pone.0029797", config=verbose()) 150 | dois <- c('10.1371/journal.pone.0001543','10.1371/journal.pone.0040117', 151 | '10.1371/journal.pone.0029797','10.1371/journal.pone.0039395') 152 | alm_ids(doi=dois, config=progress()) 153 | 154 | # Data from other sources 155 | ## Crossref article data 156 | ### Pass in a different URL - no key needed 157 | api_url <- "http://det.labs.crossref.org/api/v5/articles" 158 | alm_ids(doi='10.1371/journal.pone.0086859', api_url = api_url) 159 | alm_ids(doi='10.11646/zootaxa.3618.1.1', api_url = api_url) 160 | alm_ids(doi='10.1016/j.jep.2013.06.007', api_url = api_url) 161 | alm_ids(doi='10.1111/j.1756-1051.2012.00099.x', api_url = api_url) 162 | 163 | ## Public Knowledge Project article data 164 | ### pass in a different url - an API key needed 165 | api_url <- 'http://pkp-alm.lib.sfu.ca/api/v5/articles' 166 | alm_ids(doi='10.3402/gha.v7.23554', api_url = api_url, key = getOption("pkpalmkey")) 167 | 168 | ## eLife 169 | ### pass in a different url - no key needed 170 | api_url <- 'http://lagotto.svr.elifesciences.org/api/v5/articles' 171 | alm_ids(doi='10.7554/eLife.00471', api_url = api_url) 172 | } 173 | } 174 | \references{ 175 | See a tutorial/vignette for alm at 176 | \url{http://ropensci.org/tutorials/alm_tutorial.html} 177 | } 178 | \seealso{ 179 | \code{\link{alm_plot}} 180 | } 181 | 182 | -------------------------------------------------------------------------------- /inst/vign/alm_vignette.Rmd: -------------------------------------------------------------------------------- 1 | 5 | 6 | ```{r, eval=TRUE, echo=FALSE} 7 | knitr::opts_chunk$set( 8 | fig.width=6, 9 | fig.height=5, 10 | fig.pos="h", 11 | message=FALSE, 12 | warning=FALSE, 13 | comment="#>", 14 | cache=TRUE 15 | ) 16 | ``` 17 | 18 | alm tutorial 19 | ============ 20 | 21 | The `alm` package is a set of functions to access article level metrics via a RESTful API from the Rails app `Lagotto` created by the Public Library of Science (PLOS). `Lagotto` is being used by PLOS, and a number of other publishers: 22 | 23 | * PLOS (all their journals) at [http://alm.plos.org/](http://alm.plos.org/) 24 | * PLOS test server at [http://labs.lagotto.io/](http://labs.lagotto.io/) 25 | * Copernicus (seems to be down for now) 26 | * Public Knowledge Project (PKP) at [http://pkp-alm.lib.sfu.ca/](http://pkp-alm.lib.sfu.ca/) 27 | * Crossref at [http://det.labs.crossref.org/](http://det.labs.crossref.org/) 28 | * eLife at [http://lagotto.svr.elifesciences.org/](http://lagotto.svr.elifesciences.org/) 29 | * Pensoft at [http://alm.pensoft.net:81/](http://alm.pensoft.net:81/) 30 | * Making Dat Count at [http://dlm.plos.org](http://dlm.plos.org) 31 | 32 | A good place to look for the status of various installations of Lagotto is this status page: http://articlemetrics.github.io/status/ (which also includes what version of Lagotto each is running) 33 | 34 | ## Help with Lagotto 35 | 36 | Lagotto has a nice support site at [http://discuss.lagotto.io/](http://discuss.lagotto.io/) for any questions about it. 37 | 38 | ## What is an article level metric? 39 | 40 | Glad you asked. The canonical URL for this is perhaps [altmetrics.org](http://altmetrics.org/manifesto/). Basically it is a metric that measures something about an article. This is in stark contrast to journal level metrics, like the [Journal Impact Factor](http://www.wikiwand.com/en/Impact_factor). 41 | 42 | ## Are there other altmetrics data providers? 43 | 44 | Yes indeedy, but see notes 45 | 46 | + [ImpactStory](http://impactstory.org/) - No open data (except for your own data) 47 | + [Altmetric.com](http://altmetric.com/) - Some open data 48 | + [PlumAnalytics](http://www.plumanalytics.com/) - No open data 49 | 50 | ## Authentication 51 | 52 | You only need an API key for the publishers PKP and Pensoft. You can set the key in your options just for the current session by executing `options(PlosApiKey = "YOUalmAPIKEY")`, or pass in to each function call with the `key` parameter, or save in your `.Rprofile` file. 53 | 54 | ## URLs 55 | 56 | The default URL is set for the PLOS data sources: http://alm.plos.org/api/v5/articles 57 | You can change this URL. For example, if you want to get data from the Crossref instance, set the `api_url` parameter to http://alm.labs.crossref.org/api/v5/articles 58 | 59 | ## Other languages 60 | 61 | If R is not your thing, there are Lagotto clients in development for [Ruby](https://github.com/articlemetrics/lagotto-rb) and [Python](https://github.com/articlemetrics/pyalm). 62 | 63 | ## Help 64 | 65 | If you are having trouble with this R package, contact [the maintainer, Scott](mailto:myrmecocystus@gmail.com). If you are having trouble with the API itself, there is a newish discussion forum for the Lagotto service at [http://discuss.lagotto.io/](http://discuss.lagotto.io/). 66 | 67 | ## Install and load 68 | 69 | Stable version from CRAN 70 | 71 | ```{r eval=FALSE} 72 | install.packages("alm") 73 | ``` 74 | 75 | Or development version from GitHub 76 | 77 | ```{r install, eval=FALSE} 78 | install.packages("devtools") 79 | devtools::install_github("ropensci/alm") 80 | ``` 81 | 82 | Load `alm` 83 | 84 | ```{r} 85 | library("alm") 86 | ``` 87 | 88 | ## Get data 89 | 90 | ```{r alm1} 91 | alm_ids(doi="10.1371/journal.pone.0029797") 92 | ``` 93 | 94 | ## Details for a single DOI 95 | 96 | ```{r alm2} 97 | out <- alm_ids(doi='10.1371/journal.pone.0029797', info='detail') 98 | ``` 99 | 100 | info 101 | 102 | ```{r} 103 | out$data$info 104 | ``` 105 | 106 | sign posts 107 | 108 | ```{r} 109 | out$data$signposts 110 | ``` 111 | 112 | totals 113 | 114 | ```{r} 115 | out$data$totals 116 | ``` 117 | 118 | history 119 | 120 | ```{r} 121 | out$data$sum_metrics 122 | ``` 123 | 124 | ## Search using various identifiers, including pubmed id, pmc id, and mendeley id 125 | 126 | A single PubMed ID (pmid) 127 | 128 | ```{r} 129 | alm_ids(pmid=22590526) 130 | ``` 131 | 132 | A single PubMed Central ID (pmcid) 133 | 134 | ```{r} 135 | alm_ids(pmcid=212692) 136 | ``` 137 | 138 | ## Search on many identifiers 139 | 140 | ```{r} 141 | dois <- c('10.1371/journal.pone.0001543','10.1371/journal.pone.0040117', 142 | '10.1371/journal.pone.0029797','10.1371/journal.pone.0039395') 143 | out <- alm_ids(doi=dois) 144 | lapply(out$data, head) 145 | ``` 146 | 147 | ## Get altmetrics by year 148 | 149 | You can also get metrics by day (`sum_metrics='day'`) or month (`sum_metrics='month'`) 150 | 151 | ```{r} 152 | alm_ids(doi='10.1371/journal.pone.0036240', sum_metrics='year') 153 | ``` 154 | 155 | ## Output an-easy-to-combine-with-other-results data.frame 156 | 157 | ```{r} 158 | alm_ids(doi='10.1371/journal.pone.0035869', total_details=TRUE)$data[,3:7] 159 | ``` 160 | 161 | ## Get detailed data for altmetrics using `almevents` 162 | 163 | ```{r} 164 | out <- alm_events(doi="10.1371/journal.pone.0029797") 165 | names(out) 166 | ``` 167 | 168 | Get the results for PubMed Central 169 | 170 | ```{r} 171 | # remove those with no data 172 | out <- out[!out %in% c("sorry, no events content yet","parser not written yet")] 173 | out[["pmc"]] 174 | ``` 175 | 176 | Get the results for twitter 177 | 178 | ```{r} 179 | out$twitter$events[1:3,] 180 | ``` 181 | 182 | ## Retrieve and plot PLOS article-level metrics signposts. 183 | 184 | ```{r fig.keep='high'} 185 | dat <- alm_signposts(doi="10.1371/journal.pone.0029797") 186 | plot_signposts(input=dat) 187 | ``` 188 | 189 | Or plot many identifiers gives a line chart 190 | 191 | ```{r fig.width=7, tidy=FALSE} 192 | library("ggplot2") 193 | dois <- c('10.1371/journal.pone.0001543','10.1371/journal.pone.0040117','10.1371/journal.pone.0029797','10.1371/journal.pone.0039395') 194 | dat <- alm_signposts(doi=dois) 195 | plot_signposts(input=dat) + 196 | theme_grey(base_size = 12) 197 | ``` 198 | 199 | Or make an interactive chart by doing `plot_signposts(input=dat, type="multiBarChart")`. Try it out! It should open in your browser and you can interact with it. 200 | 201 | ## Density and histogram plots from PLOS Article Level Metrics data 202 | 203 | Note: Do you the key below in the `searchplos` call in this example, but if you plan to use rplos more, get your own API key [here](http://api.plos.org/). 204 | 205 | ```{r} 206 | library('rplos') 207 | library('plyr') 208 | dois <- searchplos(q='science', fl="id", fq=list('cross_published_journal_key:PLoSONE', 'doc_type:full', 'publication_date:[2010-01-01T00:00:00Z TO 2010-12-31T23:59:59Z]'), limit=75) 209 | ``` 210 | 211 | Remove non-full article DOIs 212 | 213 | ```{r} 214 | dois <- dois$data$id 215 | dois <- dois[!grepl("annotation", dois)] 216 | ``` 217 | 218 | Collect altmetrics data and combine to a `data.frame` with `ldply` 219 | 220 | ```{r} 221 | alm <- alm_ids(doi=dois, total_details=TRUE) 222 | alm <- ldply(alm$data) 223 | ``` 224 | 225 | The default plot 226 | 227 | ```{r fig.width=5, fig.height=4} 228 | plot_density(alm) 229 | ``` 230 | 231 | You can change the color of the density plot 232 | 233 | ```{r fig.width=5, fig.height=4} 234 | plot_density(alm, color="#EFA5A5") 235 | ``` 236 | 237 | Pass in a title or description subtending the title 238 | 239 | ```{r fig.width=5, fig.height=4} 240 | plot_density(alm, title="Scopus citations from 2010") 241 | ``` 242 | 243 | Plot a particular source 244 | 245 | ```{r fig.width=5, fig.height=4} 246 | plot_density(alm, source="crossref_total") 247 | ``` 248 | 249 | Plot many sources in different panels in the same plot, and pass in colors just for fun 250 | 251 | ```{r fig.width=7, fig.height=6, tidy=FALSE} 252 | plot_density(input=alm, 253 | source=c("counter_html","crossref_total","pubmed_total","scopus_total"), 254 | color=c("#83DFB4","#EFA5A5","#CFD470","#B2C9E4")) + 255 | theme_grey(base_size = 12) 256 | ``` 257 | 258 | ## CrossRef article level metrics 259 | 260 | Notice that we are passing the base url for the Crossref API, whereas the default is for the PLOS url [http://alm.plos.org/api/v5/articles](http://alm.plos.org/api/v5/articles). 261 | 262 | ```{r} 263 | url <- "http://det.labs.crossref.org/api/v5/articles" 264 | dois <- c("10.1371/journal.pone.0086859", "10.1038/nature12990", "10.5860/choice.51-3037") 265 | alm_ids(doi=dois, api_url = url) 266 | ``` 267 | -------------------------------------------------------------------------------- /inst/vign/.Rhistory: -------------------------------------------------------------------------------- 1 | out <- df_to_SpatialPointsDataFrame(input, ...) 2 | } else { 3 | out <- df_to_SpatialPolygonsDataFrame(input) 4 | } 5 | unlink(paste0(path.expand(destpath), outfilename, ".geojson")) 6 | writeOGR(out, paste0(path.expand(destpath), outfilename, ".geojson"), outfilename, 7 | driver = "GeoJSON") 8 | message(paste0("Success! File is at ", path.expand(destpath), outfilename, 9 | ".geojson")) 10 | } 11 | list_to_geojson(input, polygon=polygon) 12 | to_geojson.list <- function(input, lat = "latitude", lon = "longitude", polygon=NULL, output='list', ...){ 13 | if(output=='list'){ 14 | x <- lapply(input, function(l) { 15 | if (is.null(l[[lat]]) || is.null(l[[lon]])) { 16 | return(NULL) 17 | } 18 | type <- ifelse(is.null(polygon), "Point", "Polygon") 19 | list(type = type, 20 | geometry = list(type = "Point", 21 | coordinates = as.numeric(c(l[[lon]], l[[lat]]))), 22 | properties = l[!(names(l) %in% c(lat, lon))]) 23 | }) 24 | setNames(Filter(function(x) !is.null(x), x), NULL) 25 | } else { 26 | list_to_geojson(input, polygon=polygon, ...) 27 | } 28 | } 29 | mylist <- list(list(latitude=30, longitude=120, marker="red"), list(latitude=30, longitude=130, marker="blue")) 30 | mylist 31 | to_geojson(mylist) 32 | to_geojson(mylist, output = "geojson") 33 | #' @method to_geojson list 34 | #' @export 35 | #' @rdname to_geojson 36 | to_geojson.list <- function(input, lat = "latitude", lon = "longitude", polygon=NULL, output='list', ...){ 37 | if(output=='list'){ 38 | x <- lapply(input, function(l) { 39 | if (is.null(l[[lat]]) || is.null(l[[lon]])) { 40 | return(NULL) 41 | } 42 | type <- ifelse(is.null(polygon), "Point", "Polygon") 43 | list(type = type, 44 | geometry = list(type = "Point", 45 | coordinates = as.numeric(c(l[[lon]], l[[lat]]))), 46 | properties = l[!(names(l) %in% c(lat, lon))]) 47 | }) 48 | setNames(Filter(function(x) !is.null(x), x), NULL) 49 | } else { 50 | list_to_geojson(input, polygon=polygon, ...) 51 | } 52 | } 53 | list_to_geojson <- function(input, destpath = "~/", outfilename = "myfile", polygon=NULL, lon, lat){ 54 | input <- do.call(rbind.fill, lapply(input, data.frame)) 55 | if(is.null(polygon)){ 56 | out <- df_to_SpatialPointsDataFrame(input, lon=lon, lat=lat) 57 | } else { 58 | out <- df_to_SpatialPolygonsDataFrame(input) 59 | } 60 | unlink(paste0(path.expand(destpath), outfilename, ".geojson")) 61 | writeOGR(out, paste0(path.expand(destpath), outfilename, ".geojson"), outfilename, 62 | driver = "GeoJSON") 63 | message(paste0("Success! File is at ", path.expand(destpath), outfilename, 64 | ".geojson")) 65 | } 66 | df_to_SpatialPolygonsDataFrame <- function(x){ 67 | x_split <- split(x, f = x$group) 68 | res <- lapply(x_split, function(y){ 69 | coordinates(y) <- c("long","lat") 70 | Polygon(y) 71 | }) 72 | res <- Polygons(res, "polygons") 73 | hh <- SpatialPolygons(list(res)) 74 | as(hh, "SpatialPolygonsDataFrame") 75 | } 76 | df_to_SpatialPointsDataFrame <- function(x, lon, lat){ 77 | coordinates(x) <- c(lon,lat) 78 | return( x ) 79 | } 80 | to_geojson(mylist) 81 | to_geojson(mylist, output = "geojson") 82 | to_geojson.list <- function(input, lat = "latitude", lon = "longitude", polygon=NULL, output='list', ...){ 83 | if(output=='list'){ 84 | x <- lapply(input, function(l) { 85 | if (is.null(l[[lat]]) || is.null(l[[lon]])) { 86 | return(NULL) 87 | } 88 | type <- ifelse(is.null(polygon), "Point", "Polygon") 89 | list(type = type, 90 | geometry = list(type = "Point", 91 | coordinates = as.numeric(c(l[[lon]], l[[lat]]))), 92 | properties = l[!(names(l) %in% c(lat, lon))]) 93 | }) 94 | setNames(Filter(function(x) !is.null(x), x), NULL) 95 | } else { 96 | list_to_geojson(input, lat=lat, lon=lon, polygon=polygon) 97 | } 98 | } 99 | to_geojson(mylist, output = "geojson") 100 | readLines("/Users/sacmac/myfile.geojson") 101 | paste0(readLines("/Users/sacmac/myfile.geojson")) 102 | paste0(readLines("/Users/sacmac/myfile.geojson"), collapse = "") 103 | fromJSON(paste0(readLines("/Users/sacmac/myfile.geojson"), collapse = "")) 104 | library(jsonlite) 105 | fromJSON(paste0(readLines("/Users/sacmac/myfile.geojson"), collapse = "")) 106 | to_geojson(mylist) 107 | ?writeOGR 108 | fromJSON(paste0(readLines("/Users/sacmac/myfile.geojson"), collapse = "")) 109 | fromJSON(paste0(readLines("/Users/sacmac/myfile.geojson"), collapse = ""), simplifyVector = FALSE) 110 | fromJSON(paste0(readLines("/Users/sacmac/myfile.geojson"), collapse = ""), simplifyVector = FALSE)[[1]] 111 | fromJSON(paste0(readLines("/Users/sacmac/myfile.geojson"), collapse = ""), simplifyVector = FALSE)$features[[1]] 112 | to_geojson(mylist)[[1]] 113 | fromJSON(paste0(readLines("/Users/sacmac/myfile.geojson"), collapse = ""), simplifyVector = FALSE)$features 114 | library(maps) 115 | data(us.cities) 116 | head(us.cities) 117 | to_geojson(input=us.cities, lat='lat', lon='long') 118 | to_geojson(input=us.cities, lat='lat', lon='long', output = "geojson") 119 | to_geojson.data.frame(input=us.cities, lat='lat', lon='long', output = "geojson") 120 | x=us.cities 121 | df_to_SpatialPolygonsDataFrame(x) 122 | head(x) 123 | res <- df_to_SpatialPointsDataFrame(input) 124 | input 125 | input=us.cities 126 | head(input) 127 | res <- df_to_SpatialPointsDataFrame(input) 128 | res <- df_to_SpatialPointsDataFrame(input, lon = lon, lat = lat) 129 | lat 130 | lon 131 | lat='lat' 132 | lon='long' 133 | res <- df_to_SpatialPointsDataFrame(input, lon = lon, lat = lat) 134 | res 135 | SpatialPolygonsDataFrame_togeojson(res) 136 | to_geojson <- function(...){ 137 | UseMethod("to_geojson") 138 | } 139 | #' @method to_geojson data.frame 140 | #' @export 141 | #' @rdname to_geojson 142 | to_geojson.data.frame <- function(input, lat = "latitude", lon = "longitude", polygon=NULL, output='list', ...){ 143 | if(output=='list'){ 144 | input <- apply(input, 1, as.list) 145 | x <- lapply(input, function(l) { 146 | if (is.null(l[[lat]]) || is.null(l[[lon]])) { 147 | return(NULL) 148 | } 149 | type <- ifelse(is.null(polygon), "Point", "Polygon") 150 | list(type = type, 151 | geometry = list(type = "Point", 152 | coordinates = as.numeric(c(l[[lon]], l[[lat]]))), 153 | properties = l[!(names(l) %in% c(lat, lon))]) 154 | }) 155 | setNames(Filter(function(x) !is.null(x), x), NULL) 156 | } else { 157 | if(is.null(polygon)){ 158 | res <- df_to_SpatialPointsDataFrame(input, lon = lon, lat = lat) 159 | } else { 160 | res <- df_to_SpatialPolygonsDataFrame(input) 161 | } 162 | SpatialPolygonsDataFrame_togeojson(res) 163 | } 164 | } 165 | #' @method to_geojson list 166 | #' @export 167 | #' @rdname to_geojson 168 | to_geojson.list <- function(input, lat = "latitude", lon = "longitude", polygon=NULL, output='list', ...){ 169 | if(output=='list'){ 170 | x <- lapply(input, function(l) { 171 | if (is.null(l[[lat]]) || is.null(l[[lon]])) { 172 | return(NULL) 173 | } 174 | type <- ifelse(is.null(polygon), "Point", "Polygon") 175 | list(type = type, 176 | geometry = list(type = "Point", 177 | coordinates = as.numeric(c(l[[lon]], l[[lat]]))), 178 | properties = l[!(names(l) %in% c(lat, lon))]) 179 | }) 180 | setNames(Filter(function(x) !is.null(x), x), NULL) 181 | } else { 182 | list_to_geojson(input, lat=lat, lon=lon, polygon=polygon) 183 | } 184 | } 185 | list_to_geojson <- function(input, destpath = "~/", outfilename = "myfile", polygon=NULL, lon, lat){ 186 | input <- do.call(rbind.fill, lapply(input, data.frame)) 187 | if(is.null(polygon)){ 188 | out <- df_to_SpatialPointsDataFrame(input, lon=lon, lat=lat) 189 | } else { 190 | out <- df_to_SpatialPolygonsDataFrame(input) 191 | } 192 | unlink(paste0(path.expand(destpath), outfilename, ".geojson")) 193 | writeOGR(out, paste0(path.expand(destpath), outfilename, ".geojson"), outfilename, 194 | driver = "GeoJSON") 195 | message(paste0("Success! File is at ", path.expand(destpath), outfilename, 196 | ".geojson")) 197 | } 198 | df_to_SpatialPolygonsDataFrame <- function(x){ 199 | x_split <- split(x, f = x$group) 200 | res <- lapply(x_split, function(y){ 201 | coordinates(y) <- c("long","lat") 202 | Polygon(y) 203 | }) 204 | res <- Polygons(res, "polygons") 205 | hh <- SpatialPolygons(list(res)) 206 | as(hh, "SpatialPolygonsDataFrame") 207 | } 208 | df_to_SpatialPointsDataFrame <- function(x, lon, lat){ 209 | coordinates(x) <- c(lon,lat) 210 | return( x ) 211 | } 212 | SpatialPolygonsDataFrame_togeojson <- function(input, destpath = "~/", outfilename = "myfile"){ 213 | unlink(paste0(path.expand(destpath), outfilename, ".geojson")) 214 | writeOGR(input, paste0(path.expand(destpath), outfilename, ".geojson"), outfilename, 215 | driver = "GeoJSON") 216 | message(paste0("Success! File is at ", path.expand(destpath), outfilename, 217 | ".geojson")) 218 | } 219 | to_geojson(input=us.cities, lat='lat', lon='long') 220 | to_geojson(input=us.cities, lat='lat', lon='long', output = "geojson") 221 | source('~/github/ropensci/togeojson/R/style_geojson.r') 222 | head(states) 223 | library(ggplot2) 224 | states <- map_data("state") 225 | head(states) 226 | nrow(states) 227 | states[1:10,] 228 | smalluscities <- us.cities[1:10,] 229 | smalluscities 230 | source('~/github/ropensci/togeojson/R/style_geojson.r') 231 | style_geojson(smalluscities) 232 | smalluscities <- us.cities[1:20,] 233 | style_geojson(smalluscities) 234 | smalluscities 235 | style_geojson(smalluscities, var = 'country.etc') 236 | style_geojson(smalluscities, var = 'country.etc', var_col = "blue") 237 | style_geojson(smalluscities, var = 'country.etc', color=c('#976AAE','#6B944D','#BD5945'), size=c('small','medium','large')) 238 | unique(smalluscities$country.etc) 239 | library(RColorBrewer) 240 | help(package = RColorBrewer) 241 | brewer.pal.info["Blues",] 242 | display.brewer.all(n=5,type="div",exact.n=TRUE) 243 | brewer.pal(7,"Greens") 244 | brewer.pal(7,"Blues") 245 | style_geojson(smalluscities, var = 'country.etc', color=brewer.pal(length(unique(smalluscities$country.etc)), "Blues"), size=c('small','medium','large')) 246 | smalluscities <- us.cities[1:12,] 247 | smalluscities 248 | unique(smalluscities$country.etc) 249 | smalluscities <- us.cities[1:10,] 250 | unique(smalluscities$country.etc) 251 | smalluscities <- us.cities[100:110,] 252 | unique(smalluscities$country.etc) 253 | smalluscities <- us.cities[200:210,] 254 | unique(smalluscities$country.etc) 255 | smalluscities <- us.cities[300:310,] 256 | unique(smalluscities$country.etc) 257 | smalluscities <- us.cities[1:8,] 258 | unique(smalluscities$country.etc) 259 | us.cities[ us.cities$country.etc %in% c('OR','CA','NY'), ] 260 | nrow(us.cities[ us.cities$country.etc %in% c('OR','CA','NY'), ]) 261 | smalluscities <- us.cities[ us.cities$country.etc %in% c('OR','CA','NY'), ] 262 | length(unique(smalluscities$country.etc)) 263 | style_geojson(smalluscities, var = 'country.etc', color=brewer.pal(length(unique(smalluscities$country.etc)), "Blues"), size=c('small','medium','large')) 264 | #' mylist <- list(list(latitude=30, longitude=120, marker="red"), 265 | #' list(latitude=30, longitude=130, marker="blue")) 266 | mylist 267 | #' mylist <- list(list(latitude=30, longitude=120, state="US"), 268 | #' list(latitude=32, longitude=130, state="OR"), 269 | #' list(latitude=38, longitude=125, state="NY"), 270 | #' list(latitude=40, longitude=128, state="VT")) 271 | mylist 272 | mylist <- list(list(latitude=30, longitude=120, state="US"), 273 | #' list(latitude=32, longitude=130, state="OR"), 274 | #' list(latitude=38, longitude=125, state="NY"), 275 | #' list(latitude=40, longitude=128, state="VT")) 276 | #' mylist <- list(list(latitude=30, longitude=120, state="US"), 277 | #' list(latitude=32, longitude=130, state="OR"), 278 | #' list(latitude=38, longitude=125, state="NY"), 279 | #' list(latitude=40, longitude=128, state="VT")) 280 | mylist <- list(list(latitude=30, longitude=120, state="US"), 281 | list(latitude=32, longitude=130, state="OR"), 282 | list(latitude=38, longitude=125, state="NY"), 283 | list(latitude=40, longitude=128, state="VT")) 284 | mylist 285 | sapply(mylist, '[[', 'state') 286 | length(unique(sapply(mylist, '[[', 'state'))) 287 | smalluscities 288 | input=smalluscities 289 | var = 'country.etc' 290 | color=brewer.pal(length(unique(smalluscities$country.etc)), "Blues") 291 | color 292 | mapping <- data.frame(var = unique(input[[var_col]]), col2 = color) 293 | is.null(var_col) & is.null(var_sym) & is.null(var_size) 294 | var_col <- var 295 | var_col 296 | mapping <- data.frame(var = unique(input[[var_col]]), col2 = color) 297 | mapping 298 | stuff <- input[[var_col]] 299 | color_vec <- with(mapping, col2[match(stuff, var)]) 300 | stuff 301 | color_vec 302 | library(shiny) 303 | runApp 304 | col_search(name="Apis") 305 | library(taxize) 306 | col_search(name="Apis") 307 | col_search(name="Apis mellifera") 308 | col_search(name=c("Apis","Puma concolor")) 309 | col_search 310 | source('~/.active-rstudio-document') 311 | load_defaults(col_Search) 312 | load_defaults(col_search) 313 | name="Apis" 314 | url <- "http://www.catalogueoflife.org/col/webservice" 315 | func <- function(x, y) { 316 | if(is.null(checklist)){NULL} else { 317 | cc <- match.arg(checklist, choices = c(2012, 2011, 2010, 2009, 2008, 2007)) 318 | if (cc %in% c(2012, 2011, 2010)){ 319 | url <- gsub("col", paste("annual-checklist/", cc, sep = ""), url) 320 | } else { 321 | url <- "http://webservice.catalogueoflife.org/annual-checklist/year/search.php" 322 | url <- gsub("year", cc, url) 323 | } 324 | } 325 | args <- compact(list(name = x, id = y, start = start)) 326 | out <- getForm(url, .params = args) 327 | tt <- xmlParse(out) 328 | toget <- c('id','name','rank','name_status') 329 | nodes <- getNodeSet(tt, "//result", fun=xmlToList) 330 | ldply(nodes, parsecoldata) 331 | } 332 | safe_func <- plyr::failwith(NULL, func) 333 | is.null(id) 334 | temp <- lapply(name, safe_func, y = NULL) 335 | library(RCurl) 336 | temp <- lapply(name, safe_func, y = NULL) 337 | library(XML) 338 | temp <- lapply(name, safe_func, y = NULL) 339 | temp 340 | temp <- col_search(name="Apis") 341 | two <- col_search(name=c("Apis","Puma concolor")) 342 | byid <- col_search(id=11935941) 343 | expect_that(names(temp), equals("Apis")) 344 | library(testthat) 345 | expect_that(names(temp), equals("Apis")) 346 | expect_that(as.character(temp[[1]]$name), equals("Apis")) 347 | expect_that(names(temp), equals("Apis")) 348 | expect_that(as.character(temp[[1]]$name), equals("Apis")) 349 | expect_that(is.null(dim(temp)), is_true()) 350 | expect_that(dim(temp[[1]]), equals(c(1,10))) 351 | expect_that(length(two), equals(2)) 352 | expect_that(dim(two[[1]]), equals(c(1,10))) 353 | expect_that(dim(do.call(rbind, lapply(two,data.frame))), equals(c(2,10))) 354 | expect_that(dim(byid[[1]]), equals(c(0,0))) 355 | dim(do.call(rbind, lapply(two,data.frame))) 356 | two 357 | col_downstream(name="Apis", downto="Species") 358 | col_downstream(name="Hemiptera", downto="Family", checklist=2011) 359 | col_downstream(name="Hemiptera", downto="Family", checklist=2010) 360 | out <- itis_downstream(tsns = 103359, "Family") 361 | out 362 | library(knitr) 363 | opts_chunk$set(results="hide", fig.show="hide", fig.keep="none") 364 | data(iris) 365 | head(iris) 366 | plot(iris$Sepal.Length, iris$Petal.Length) 367 | library(ggplot2) 368 | data(diamonds) 369 | head(diamonds) 370 | str(diamonds) 371 | plot(diamonds$carat, diamonds$price) 372 | qplot(carat, price, data=diamonds) 373 | qplot(carat, price, data=diamonds, col=clarity) 374 | qplot(carat, price, data=diamonds, facets = ~clarity) 375 | qplot(carat, price, data=diamonds, facets = ~color) 376 | qplot(carat, price, data=diamonds, facets = clarity~color) 377 | getOption("SunlightLabsKey", stop("need an API key for Sunlight Labs")) 378 | install_github("takluyver/IRkernel", pull = 14) 379 | install_github("takluyver/IRkernel", pull = '14') 380 | install_github("takluyver/IRkernel", ref = NULL, pull = '14') 381 | update.packages("jsonlite") 382 | install_github("jeroenooms/jsonlite") 383 | install_github("takluyver/IRkernel", ref = NULL, pull = '14') 384 | library(roxygen2); library(testthat) 385 | alm <- "~/github/ropensci/alm" 386 | document(alm); install(alm) 387 | document(alm); install(alm) 388 | document(alm) 389 | install(alm) 390 | library(roxygen2); library(testthat) 391 | alm <- "~/github/ropensci/alm" 392 | # document(alm); install(alm) 393 | library(alm) 394 | library(alm) 395 | check(alm) 396 | library(roxygen2); library(testthat) 397 | alm <- "~/github/ropensci/alm" 398 | check(alm) 399 | setwd("~/github/ropensci/alm") 400 | setwd("~/github/ropensci/alm/inst//vign") 401 | library(knitr) 402 | knit("alm_vignette.Rmd") 403 | library(rplos); library(plyr) 404 | dois <- searchplos(q='science', fl="id", fq=list('cross_published_journal_key:PLoSONE', 'doc_type:full', 'publication_date:[2010-01-01T00:00:00Z TO 2010-12-31T23:59:59Z]'), limit=20) 405 | dois 406 | knit("alm_vignette.Rmd") 407 | dat <- signposts(doi="10.1371/journal.pone.0029797") 408 | dat 409 | plot_signposts(input=dat) 410 | plot_signposts(input=dat) + theme_bw(base_size = 12) 411 | dois <- c('10.1371/journal.pone.0001543','10.1371/journal.pone.0040117','10.1371/journal.pone.0029797','10.1371/journal.pone.0039395') 412 | dat <- signposts(doi=dois) 413 | plot_signposts(input=dat) + theme_grey(base_size = 12) 414 | dois <- searchplos(q='science', fl="id", fq=list('cross_published_journal_key:PLoSONE', 'doc_type:full', 'publication_date:[2010-01-01T00:00:00Z TO 2010-12-31T23:59:59Z]'), limit=200) 415 | dois <- dois$id 416 | dois <- dois[!grepl("annotation", dois)] 417 | alm <- alm(doi=dois, total_details=TRUE) 418 | alm <- ldply(alm) 419 | plot_density(input=alm, source=c("counter_total","crossref_citations","twitter_total","wos_citations"), color=c("#83DFB4","#EFA5A5","#CFD470","#B2C9E4")) + theme_grey(base_size = 12) 420 | plot_density(input=alm, source=c("counter_total","crossref_citations","twitter_total","wos_citations"), color=c("#83DFB4","#EFA5A5","#CFD470","#B2C9E4")) + theme_b(base_size = 12) 421 | plot_density(input=alm, source=c("counter_total","crossref_citations","twitter_total","wos_citations"), color=c("#83DFB4","#EFA5A5","#CFD470","#B2C9E4")) 422 | plot_density(input=alm, source=c("counter_total","crossref_citations","twitter_total","wos_citations"), color=c("#83DFB4","#EFA5A5","#CFD470","#B2C9E4")) + theme_bw(base_size = 12) 423 | plot_density(input=alm, source=c("counter_total","crossref_citations","twitter_total","wos_citations"), color=c("#83DFB4","#EFA5A5","#CFD470","#B2C9E4")) + theme_bw(base_size = 162) 424 | plot_density(input=alm, source=c("counter_total","crossref_citations","twitter_total","wos_citations"), color=c("#83DFB4","#EFA5A5","#CFD470","#B2C9E4")) + theme_bw(base_size = 6) 425 | knit("alm_vignette.Rmd") 426 | knit("alm_vignette.Rmd") 427 | url <- "http://alm.labs.crossref.org/api/v3/articles" 428 | dois <- c("10.1371/journal.pone.0086859", "10.1038/nature12990", "10.5860/choice.51-3037", "10.1111/jeb.12289") 429 | alm(doi=dois, url = url, key=getOption("crossrefalmkey")) 430 | dois <- c("10.1371/journal.pone.0086859", "10.1038/nature12990", "10.5860/choice.51-3037") 431 | alm(doi=dois, url = url, key=getOption("crossrefalmkey")) 432 | knit("alm_vignette.Rmd") 433 | library(roxygen2); library(testthat) 434 | alm <- "~/github/ropensci/alm" 435 | document(alm); install(alm) 436 | library(roxygen2); library(testthat) 437 | alm <- "~/github/ropensci/alm" 438 | document(alm); install(alm) 439 | library(roxygen2); library(testthat) 440 | alm <- "~/github/ropensci/alm" 441 | library(alm) 442 | test_package("alm") 443 | out <- almevents(doi="10.1371/journal.pone.0029797") 444 | out <- out[!out %in% c("sorry, no events content yet","parser not written yet")] # remove those with no data 445 | expect_that(out, is_a("list")) 446 | expect_that(out[["pmc"]], is_a("data.frame")) 447 | expect_that(nrow(out[["pmc"]]), equals(12)) 448 | nrow(out[["pmc"]]) 449 | expect_that(nrow(out[["pmc"]]), equals(25)) 450 | ncol(out[["twitter"]]) 451 | expect_that(ncol(out[["twitter"]]), equals(6)) 452 | length(out[c("twitter","crossref")]) 453 | expect_that(length(out[c("twitter","crossref")]), equals(2)) 454 | library(roxygen2); library(testthat) 455 | alm <- "~/github/ropensci/alm" 456 | document(alm); install(alm) 457 | library(roxygen2); library(testthat) 458 | alm <- "~/github/ropensci/alm" 459 | # document(alm); install(alm) 460 | library(alm) 461 | # check(alm) 462 | # run_examples(alm, run=FALSE) 463 | # build(alm) 464 | # build_win(alm, version="R-devel") 465 | test_package("alm") 466 | build_win(alm) 467 | setwd("") 468 | setwd("~") 469 | build(alm) 470 | build_win(alm, version="R-devel") 471 | library(roxygen2); library(testthat) 472 | alm <- "~/github/ropensci/alm" 473 | document(alm); install(alm) 474 | library(roxygen2); library(testthat) 475 | alm <- "~/github/ropensci/alm" 476 | # document(alm); install(alm) 477 | library(alm) 478 | # check(alm) 479 | # run_examples(alm, run=FALSE) 480 | build(alm) 481 | key <- "MUvThuaeRNV2cNs" 482 | library(alm) 483 | dat <- alm(doi="10.1371/journal.pone.0029797", key=key) 484 | key 485 | getOption("PlosApiKey") 486 | key <- "rkfDr76z75benY3pytM1" 487 | dat <- alm(doi="10.1371/journal.pone.0029797", key=key) 488 | dat 489 | library(roxygen2); library(testthat) 490 | alm <- "~/github/ropensci/alm" 491 | document(alm); install(alm) 492 | library(roxygen2); library(testthat) 493 | alm <- "~/github/ropensci/alm" 494 | # document(alm); install(alm) 495 | library(alm) 496 | # check(alm) 497 | # run_examples(alm, run=FALSE) 498 | build(alm) 499 | apropos("ascii") 500 | tools::showNonASCIIfile(file = "~/github/ropensci/alm/vignettes/alm_vignette.Rmd") 501 | tools::showNonASCIIfile(file = "~/github/ropensci/alm/vignettes/alm_vignette.Rmd") 502 | setwd("~/github/ropensci/alm/inst//vign") 503 | library(knitr) 504 | knit("alm_vignette.Rmd") 505 | library(roxygen2); library(testthat) 506 | alm <- "~/github/ropensci/alm" 507 | document(alm); install(alm) 508 | library(roxygen2); library(testthat) 509 | alm <- "~/github/ropensci/alm" 510 | library(alm) 511 | build(alm) 512 | build_win(alm) 513 | -------------------------------------------------------------------------------- /R/alm_events.R: -------------------------------------------------------------------------------- 1 | #' Retrieve PLoS article-level metrics (ALM) events. 2 | #' 3 | #' Events are the details of the metrics that are counted related to PLoS papers. 4 | #' 5 | #' @importFrom reshape sort_df 6 | #' @importFrom plyr rbind.fill 7 | #' @export 8 | #' @param doi Digital object identifier for an article in PLoS Journals (character) 9 | #' @param pmid PubMed object identifier (numeric) 10 | #' @param pmcid PubMed Central object identifier (numeric) 11 | #' @param wos Web of Science identifier (character) 12 | #' @param scp Scopus identifier (character) 13 | #' @param url Canonical URL (character) 14 | #' @param source_id (character) Name of source to get ALM information for. One source only. 15 | #' You can get multiple sources via a for loop or lapply-type call. 16 | #' @param publisher_id (character) Metrics for articles by a given publisher, using the Crossref 17 | #' \code{member_id}. 18 | #' @param compact (logical) Whether to make output compact or not. If TRUE (default), remove 19 | #' empty sources. 20 | #' @param key (character) Your API key, either enter, or loads from .Rprofile. Only required for 21 | #' PKP source, not the others. 22 | #' @param api_url API endpoint, defaults to http://alm.plos.org/api/v3/articles (character) 23 | #' @param ... optional additional curl options (debugging tools mostly) 24 | #' @details You can only supply one of the parmeters doi, pmid, pmcid, and mendeley. 25 | #' 26 | #' Query for as many articles at a time as you like. Though queries are broken 27 | #' up in to smaller bits of 30 identifiers at a time. 28 | #' 29 | #' If you supply both the days and months parameters, days takes precedence, 30 | #' and months is ignored. 31 | #' 32 | #' You can get events from many different sources. After calling alm_events, 33 | #' then index the output by the data provider you want. The options are: 34 | #' bloglines, citeulike, connotea, crossref, nature, postgenomic, pubmed, 35 | #' scopus, plos, researchblogging, biod, webofscience, pmc, facebook, 36 | #' mendeley, twitter, wikipedia, and scienceseeker. 37 | #' 38 | #' Beware that some data source are not parsed yet, so there may be event data 39 | #' but it is not provided yet as it is so messy to parse. 40 | #' 41 | #' See more info on PLOS's relative metrics event source here 42 | #' \url{http://www.plosone.org/static/almInfo#relativeMetrics} 43 | #' @return PLoS altmetrics as data.frame's. 44 | #' @references See a tutorial/vignette for alm at 45 | #' \url{http://ropensci.org/tutorials/alm_tutorial.html} 46 | #' @examples \dontrun{ 47 | #' # For one article 48 | #' out <- alm_events(doi="10.1371/journal.pone.0029797") 49 | #' names(out) # names of sources 50 | #' # remove those with no data 51 | #' out <- out[!out %in% c("sorry, no events content yet","parser not written yet")] 52 | #' out[["pmc"]] # get the results for PubMed Central 53 | #' out[["twitter"]] # get the results for twitter 54 | #' out[["plos_comments"]] # get the results for PLOS comments, sorta messy 55 | #' out[c("twitter","crossref")] # get the results for two sources 56 | #' 57 | #' # Another example 58 | #' (out <- alm_events(doi="10.1371/journal.pone.0001543")) 59 | #' # remove those with no data 60 | #' out <- out[!out %in% c("sorry, no events content yet","parser not written yet")] 61 | #' names(out) 62 | #' out[['scopus']] 63 | #' out[['mendeley']] 64 | #' out[['figshare']] 65 | #' out[['pubmed']] 66 | #' 67 | #' # Two doi's 68 | #' dois <- c('10.1371/journal.pone.0001543','10.1371/journal.pone.0040117') 69 | #' out <- alm_events(doi=dois) 70 | #' out[[1]] 71 | #' out[[2]] 72 | #' out[[1]][["figshare"]]$events 73 | #' 74 | #' # Many pmcid's 75 | #' out <- alm_events(pmcid=c(212692,2082661)) 76 | #' names(out) 77 | #' out['212692'] 78 | #' 79 | #' # Many pmid's 80 | #' out <- alm_events(pmid = c(19300479, 19390606, 19343216)) 81 | #' names(out) 82 | #' out['19390606'] 83 | #' 84 | #' # Specify two specific sources 85 | #' ## You have to do so through lapply, or similar approach 86 | #' lapply(c("crossref","twitter"), 87 | #' function(x) alm_events(doi="10.1371/journal.pone.0035869", source_id=x)) 88 | #' 89 | #' # Figshare data 90 | #' alm_events(doi="10.1371/journal.pone.0069841", source_id='figshare') 91 | #' 92 | #' # Datacite data 93 | #' alm_events("10.1371/journal.pone.0012090", source_id='datacite') 94 | #' 95 | #' # Reddit data 96 | #' alm_events("10.1371/journal.pone.0015552", source_id='reddit') 97 | #' 98 | #' # Wordpress data 99 | #' alm_events("10.1371/journal.pcbi.1000361", source_id='wordpress') 100 | #' 101 | #' # Articlecoverage data 102 | #' alm_events(doi="10.1371/journal.pmed.0020124", source_id='articlecoverage') 103 | #' 104 | #' # Articlecoveragecurated data 105 | #' headfoo <- function(x) head(x$articlecoveragecurated$events) 106 | #' headfoo(alm_events(doi="10.1371/journal.pone.0088278", source_id='articlecoveragecurated')) 107 | #' headfoo(alm_events(doi="10.1371/journal.pmed.1001587", source_id='articlecoveragecurated')) 108 | #' 109 | #' # F1000 Prime data 110 | #' alm_events(doi="10.1371/journal.pbio.1001041", source_id='f1000') 111 | #' dois <- c('10.1371/journal.pmed.0020124','10.1371/journal.pbio.1001041', 112 | #' '10.1371/journal.pbio.0040020') 113 | #' res <- alm_events(doi = dois, source_id='f1000') 114 | #' res[[3]] 115 | #' 116 | #' # by source_id only 117 | #' alm_events(source_id = "crossref") 118 | #' alm_events(source_id = "reddit") 119 | #' 120 | #' # by publisher_id only 121 | #' alm_events(publisher_id = 340) 122 | #' 123 | #' # search the software lagotto sever 124 | #' urls <- c("https://github.com/najoshi/sickle","https://github.com/lh3/wgsim", 125 | #' "https://github.com/jstjohn/SeqPrep") 126 | #' dat <- alm_events(url = urls, api_url = "http://software.lagotto.io/api/v5/articles") 127 | #' } 128 | #' 129 | #' @examples \dontest{ 130 | #' # Crossref article data 131 | #' # You need to get an API key first, and pass in a different URL 132 | #' api_url <- "http://alm.labs.crossref.org/api/v3/articles" 133 | #' key <- getOption("crossrefalmkey") 134 | #' # With wikipedia data 135 | #' alm_events(doi='10.1371/journal.pone.0086859', api_url = api_url, key = key) 136 | #' # With facebook data 137 | #' alm(doi='10.1080/15459624.2013.816432', api_url = api_url, key = key) 138 | #' alm_events(doi='10.1080/15459624.2013.816432', url = url, key = key) 139 | #' # With CrossRef citation data - no events data for citations though... 140 | #' alme(doi='10.1021/cr400135x', api_url = api_url, key = key) 141 | #' alm_events(doi='10.1021/cr400135x', api_url = api_url, key = key) 142 | #' 143 | #' # Public Knowledge Project article data 144 | #' # You need to get an API key first, and pass in a different URL 145 | #' api_url <- 'http://pkp-alm.lib.sfu.ca/api/v3/articles' 146 | #' alm_events(doi='10.3402/gha.v7.23554', api_url = api_url, key = getOption("pkpalmkey")) 147 | #' 148 | #' # Copernicus publishers article data 149 | #' # You need to get an API key first, and pass in a different URL 150 | #' api_url <- 'http://metricus.copernicus.org/api/v3/articles' 151 | #' alm_events(doi='10.5194/acpd-14-8287-2014', api_url = api_url, key = getOption("copernicusalmkey")) 152 | #' } 153 | 154 | alm_events <- function(doi = NULL, pmid = NULL, pmcid = NULL, wos = NULL, scp = NULL, url = NULL, 155 | source_id = NULL, publisher_id = NULL, compact = TRUE, key = NULL, 156 | api_url='http://alm.plos.org/api/v5/articles', ...) 157 | { 158 | id <- almcompact(list(doi=doi, pmid=pmid, pmcid=pmcid, wos=wos, scp=scp, url=url, source_id=source_id, publisher_id=publisher_id)) 159 | # id <- almcompact(list(doi=doi, pmid=pmid, pmcid=pmcid, wos=wos, scp=scp, url=url)) 160 | if(length(delsp(id)) > 1) { 161 | stop("Only supply one of: doi, pmid, pmcid, wos, scp, url") 162 | } 163 | if(length(source_id) > 1) stop("You can only supply one source_id") 164 | if(length(publisher_id) > 1) stop("You can only supply one publisher_id") 165 | 166 | parse_events <- function() { 167 | args <- almcompact(list(api_key = key, info = 'detail', source_id = source_id, 168 | publisher_id=publisher_id, type = idtype(names(id)))) 169 | if(length(almcompact(list(doi=doi, pmid=pmid, pmcid=pmcid, wos=wos, url=url))) == 0){ 170 | if(length(id) == 0) stop("Please provide one of: doi, pmid, pmcid, wos, scp, url, source_id, or publisher_id") 171 | ttt <- alm_GET(api_url, args, ...) 172 | events <- lapply(ttt$data, function(x) x$sources) 173 | } else { 174 | if(length(delsp(id)[[1]]) == 1){ 175 | passid <- if(names(delsp(id)) == "doi") gsub("/", "%2F", delsp(id)) else delsp(id) 176 | ttt <- alm_GET(api_url, c(args, ids = passid[[1]]), ...) 177 | events <- lapply(ttt$data, function(x) x$sources) 178 | } else 179 | if(length(delsp(id)[[1]]) > 1){ 180 | if(length(delsp(id)[[1]]) > 50){ 181 | slice <- function(x, n) split(x, as.integer((seq_along(x) - 1) / n)) 182 | idsplit <- slice(delsp(id)[[1]], 50) 183 | repeatit <- function(y) { 184 | id2 <- if(names(delsp(id)) == "doi") paste(sapply(y, function(x) gsub("/", "%2F", x)), collapse=",") else paste(delsp(id)[[1]], collapse=",") 185 | alm_POST(api_url, c(args, ids = id2), ...) 186 | } 187 | temp <- lapply(idsplit, repeatit) 188 | ttt <- do.call(c, lapply(temp, "[[", "data")) 189 | events <- unname(lapply(ttt, function(x) x$sources)) 190 | } else { 191 | id2 <- concat_ids(delsp(id)) 192 | ttt <- alm_POST(x = api_url, y = c(args, ids = id2), ...) 193 | events <- lapply(ttt$data, function(x) x$sources) 194 | } 195 | } 196 | } 197 | 198 | # get juse the events data 199 | # events <- lapply(ttt$data, function(x) x$sources) 200 | 201 | # Function to extract and parse events data for each source 202 | getevents <- function(x, label=NULL){ 203 | 204 | # Parser code 205 | parsers <- function(y){ 206 | 207 | sorry <- "sorry, no events content yet" 208 | 209 | if(y$name == "counter"){ 210 | if(length(y$events)==0){paste(sorry)} else 211 | { 212 | year <- as.numeric(sapply(y$events, `[[`, "year")) 213 | month <- as.numeric(sapply(y$events, `[[`, "month")) 214 | pdf_views <- as.numeric(sapply(y$events, `[[`, "pdf_views")) 215 | html_views <- as.numeric(sapply(y$events, `[[`, "html_views")) 216 | xml_views <- as.numeric(sapply(y$events, `[[`, "xml_views")) 217 | df <- data.frame(year, month, pdf_views, html_views, xml_views, stringsAsFactors = FALSE) 218 | list(events_url=y$events_url, events=df, csl=y$events_csl) 219 | } 220 | } else if(y$name == "citeulike"){ 221 | if(length(y$events)==0){paste(sorry)} else 222 | { 223 | eventspar <- lapply(y$events, data.frame, stringsAsFactors = FALSE) 224 | csl <- y$events_csl 225 | list(events_url=y$events_url, events=eventspar, csl=csl) 226 | } 227 | } else if(y$name == "crossref"){ 228 | if(length(y$events)==0){paste(sorry)} else 229 | { 230 | parsecrossref <- function(x) { 231 | if(is.null(x[[1]][["publication_type"]])){ 232 | x[[1]][["publication_type"]] <- NA 233 | } 234 | if(!("contributors" %in% names(x[[1]]))){ 235 | x[[1]][["contributors"]] <- list(contributor=NA) 236 | x[[1]]$issn <- paste(x[[1]]$issn, collapse="; ") 237 | data.frame(x[[1]]) 238 | } else if(length(x[[1]]$contributors$contributor[[1]])>1){ 239 | x[[1]]$contributors$contributor <- 240 | paste(sapply(x[[1]]$contributors$contributor, 241 | function(x) paste(x[1:2], collapse=" ")), collapse="; ") 242 | x[[1]]$issn <- paste(x[[1]]$issn, collapse="; ") 243 | data.frame(x[[1]]) 244 | } else { 245 | x[[1]]$contributors$contributor <- 246 | paste(x[[1]]$contributors$contributor[1:2], collapse=" ") 247 | x[[1]]$issn <- paste(x[[1]]$issn, collapse="; ") 248 | data.frame(x[[1]]) 249 | } 250 | } 251 | eventspar <- ldply(y$events, parsecrossref) 252 | csl <- ldply(y$events_csl, parse_csl) 253 | list(events_url=y$events_url, events=eventspar, events_csl=csl) 254 | } 255 | } else if(y$name == "nature"){ 256 | if(length(y$events)==0){paste(sorry)} else 257 | { 258 | parsenature <- function(x){ 259 | temp <- x$event 260 | blog_ <- data.frame(temp$blog[names(temp$blog) %in% c('title','url')], stringsAsFactors = FALSE) 261 | names(blog_) <- c('blog_title','blog_url') 262 | post_ <- data.frame(temp[names(temp) %in% c('title','num_words','url','percent_complex_words','created_at')], stringsAsFactors = FALSE) 263 | names(post_) <- c('post_percent_complex_words','post_created_at','post_title','post_url','post_num_words') 264 | cbind(blog_, post_) 265 | } 266 | eventspar <- ldply(y$events, parsenature) 267 | csl <- ldply(y$events_csl, parse_csl) 268 | list(events_url=y$events_url, events=eventspar, events_csl=csl) 269 | } 270 | } else if(y$name == "researchblogging"){ 271 | if(length(y$events)==0){paste(sorry)} else 272 | { 273 | parserblogging <- function(w){ 274 | temp <- w$event 275 | ss <- temp[names(temp) %in% c('post_title','blog_name','blogger_name','published_date','post_url')] 276 | ss[sapply(ss, is.null)] <- NA 277 | bloginfo <- data.frame(ss, stringsAsFactors = FALSE) 278 | if(length(temp$citations$citation[[1]])>1){ 279 | citations <- paste(sapply(temp$citations$citation, function(z) z$doi), sep="", collapse=",") 280 | } else 281 | { 282 | citations <- temp$citations$citation$doi 283 | } 284 | cbind(bloginfo, citations) 285 | } 286 | df <- do.call(rbind, lapply(y$events, parserblogging)) 287 | list(events_url=y$events_url, events=df, csl=y$events_csl) 288 | } 289 | } else if(y$name == "biod"){ 290 | if(length(y$events)==0){paste(sorry)} else 291 | { 292 | if(length(y$events) > 1){ 293 | do.call(rbind, lapply(y$events, data.frame)) 294 | } else 295 | { 296 | y$events 297 | } 298 | } 299 | } else if(y$name == "pubmed"){ 300 | if(length(y$events)==0){paste(sorry)} else { 301 | eventspar <- ldply(y$events, function(x) data.frame(x[c("event","event_url")])) 302 | list(events_url=y$events_url, events=eventspar, events_csl=y$events_csl) 303 | } 304 | } else if(y$name == "facebook"){ 305 | if(length(y$events)==0){paste(sorry)} else 306 | { 307 | parsefb <- function(x){ 308 | x[sapply(x, is.null)] <- "none" 309 | data.frame(x, stringsAsFactors = FALSE) 310 | } 311 | df <- ldply(y$events, parsefb) 312 | list(events_url=y$events_url, events=df, csl=y$events_csl) 313 | } 314 | } else if(y$name == "mendeley"){ 315 | if(length(y$events)==0){paste(sorry)} else 316 | { 317 | # parsemendeley <- function(mm){ 318 | # readers <- data.frame(name="readers", value=mm$readers, stringsAsFactors = FALSE) 319 | # disc <- if(length(mm$discipline) > 1){ 320 | # ldply(mm$discipline, function(x) data.frame(x, stringsAsFactors = FALSE))[,-1] 321 | # } else { data.frame(mm$discipline, stringsAsFactors = FALSE)[,-1] } 322 | # country <- ldply(mm$country, function(x) data.frame(x, stringsAsFactors = FALSE)) 323 | # status <- ldply(mm$status, function(x) data.frame(x, stringsAsFactors = FALSE)) 324 | # dfs <- list(readers = readers, discipline = disc, country = country, status = status) 325 | # ldply(dfs) 326 | # } 327 | # df <- parsemendeley(y$events) 328 | list(events_url=y$events_url, events=y$events, csl=y$events_csl) 329 | } 330 | } else if(y$name == "twitter"){ 331 | if(length(y$events)==0){paste(sorry)} else 332 | { 333 | temp <- ldply(y$events, function(f){ 334 | data.frame(f$event, event_url=f$event_url, event_time=f$event_time, stringsAsFactors = FALSE) 335 | }) 336 | csl <- ldply(y$events_csl, parse_csl) 337 | list(events_url=y$events_url, events=temp, csl=csl) 338 | } 339 | } else if(y$name == "wikipedia"){ 340 | if(length(y$events)==0){paste(sorry)} else { 341 | df <- ldply(y$events, function(w) { 342 | data.frame(w$event, stringsAsFactors = FALSE) 343 | }) 344 | csldf <- ldply(y$events, function(w) { 345 | parse_csl(w$event_csl) 346 | }) 347 | list(events_url = y$events_url, events = df, csl = csldf) 348 | } 349 | } else if(y$name == "bloglines"){ 350 | if(length(y$events)==0){paste(sorry)} else 351 | { 352 | parsebloglines <- function(x){ 353 | temp <- data.frame(t(x$event)) 354 | if(any(names(temp) %in% "author")==TRUE && any(names(temp) %in% "site_name")==TRUE) 355 | { 356 | temp2 <- temp[,c("site_name","author")] 357 | } else 358 | { 359 | temp2 <- data.frame(site_name=temp$site_name, author="none") 360 | } 361 | cbind(temp2, event_url=x$event_url) 362 | } 363 | ldply(y$events, parsebloglines) 364 | } 365 | } else if(y$name == "postgenomic"){ 366 | if(length(y$events)==0){paste(sorry)} else 367 | { 368 | temp <- y$events[[1]] 369 | name <- temp$event$blog_name 370 | eventurl <- temp$event_url 371 | dois <- sapply(temp$event$citing, function(x) x$doi_id ) 372 | list(blog_name=name, event_url=eventurl, dois=dois) 373 | } 374 | } else if(y$name == "scopus"){ 375 | if(length(y$events)==0){paste(sorry)} else 376 | { 377 | csl <- ldply(y$events_csl, parse_csl) 378 | list(events_url=y$events_url, events=y$events, events_csl=csl) 379 | } 380 | } else if(y$name == "wos"){ 381 | if(length(y$events)==0){paste(sorry)} else 382 | { 383 | if(length(y$events) > 1){ 384 | ldply(y$events, function(x) data.frame(t(x))) 385 | } else 386 | { 387 | y$events 388 | } 389 | } 390 | } else if(y$name == "pmc"){ 391 | if(length(y$events)==0){paste(sorry)} else 392 | { 393 | df <- ldply(y$events, data.frame, stringsAsFactors=FALSE) 394 | list(events_url=y$events_url, events=df, csl=y$events_csl) 395 | } 396 | } else if(y$name == "connotea"){ 397 | if(length(y$events)==0){paste(sorry)} else 398 | { paste("parser not written yet") } 399 | } else if(y$name == "scienceseeker"){ 400 | if(length(y$events)==0){paste(sorry)} else 401 | { 402 | parsesciseeker <- function(xx){ 403 | temp <- xx$event 404 | info <- temp[c('title','author')] 405 | recommendations <- data.frame(t(sapply(temp$`ss:community`$`ss:recommendations`, function(x) x[[2]]))) 406 | names(recommendations) <- c("user","editor") 407 | categories <- paste(sapply(temp$category, function(x) x[[1]]), collapse=",") 408 | 409 | cbind(info, recommendations, categories=categories, event_url=xx$event_url) 410 | } 411 | df <- ldply(y$events, parsesciseeker) 412 | list(events_url=y$events_url, events=df, csl=y$events_csl) 413 | } 414 | } else if(y$name == "relativemetric"){ 415 | if(length(y$events)==0){paste(sorry)} else 416 | { 417 | meta <- y$events[names(y$events) %in% c("start_date","end_date")] 418 | data <- do.call(rbind.fill, 419 | lapply(y$events$subject_areas, function(x) 420 | data.frame(subject_area=x[[1]], average_usage=t(data.frame(x[[2]])), stringsAsFactors = FALSE) 421 | ) 422 | ) 423 | list(events_url=y$events_url, events=list(meta=meta, data=data), csl=y$events_csl) 424 | } 425 | } else if(y$name == "f1000"){ 426 | if(length(y$events)==0){paste(sorry)} else 427 | { 428 | eventsdat <- ldply(y$events, function(b){ 429 | data.frame(lapply(b$event, function(bb){ 430 | tmp <- if(length(bb) > 1) paste(do.call(c, bb), collapse = "; ") else bb 431 | if(length(tmp) == 1) unlist(tmp) else tmp 432 | }), stringsAsFactors=FALSE) 433 | }) 434 | list(events_url=y$events_url, events=eventsdat, csl=y$events_csl) 435 | } 436 | } else if(y$name == "figshare"){ 437 | if(length(y$events)==0){paste(sorry)} else 438 | { 439 | eventsdat <- lapply(y$events, function(b){ 440 | sapply(b, function(bb){ 441 | tmp <- if(length(bb) > 1) do.call(c, bb) else bb 442 | if(length(tmp) == 1) unlist(tmp) else tmp 443 | }) 444 | }) 445 | list(events_url=y$events_url, events=eventsdat, csl=y$events_csl) 446 | } 447 | } else if(y$name == "wordpress"){ 448 | if(length(y$events)==0){paste(sorry)} else 449 | { 450 | eventsdat <- ldply(y$events, function(b){ 451 | data.frame(b$event, event_time=b$event_time, event_url=b$event_url, stringsAsFactors = FALSE) 452 | }) 453 | csl <- ldply(y$events_csl, parse_csl) 454 | list(events_url=y$events_url, events=eventsdat, csl=csl) 455 | } 456 | } else if(y$name == "pmceurope"){ 457 | if(length(y$events)==0){paste(sorry)} else 458 | { 459 | y$events 460 | } 461 | } else if(y$name == "pmceuropedata"){ 462 | if(length(y$events)==0){paste(sorry)} else 463 | { 464 | list(events_url=y$events_url, events=y$events, csl=y$events_csl) 465 | } 466 | } else if(y$name == "openedition"){ 467 | if(length(y$events)==0){paste(sorry)} else 468 | { 469 | y$events 470 | } 471 | } else if(y$name == "reddit"){ 472 | if(length(y$events)==0){paste(sorry)} else 473 | { 474 | eventsdat <- 475 | lapply(y$events, function(b){ 476 | tmp <- b$event[ !names(b$event) %in% c('selftext_html','selftext') ] 477 | tmp[sapply(tmp, length)==0] <- NA 478 | list(data=data.frame(tmp, stringsAsFactors = FALSE), 479 | details=list(selftext_html=b$event$selftext_html, selftext=b$event$selftext)) 480 | }) 481 | csl <- ldply(y$events_csl, parse_csl) 482 | list(events_url=y$events_url, events=eventsdat, csl=csl) 483 | } 484 | } else if(y$name == "datacite"){ 485 | if(length(y$events)==0){paste(sorry)} else 486 | { 487 | eventsdat <- ldply(y$events, function(b){ 488 | b$event <- sapply(b$event, function(v) if(length(v) > 1) paste(v, collapse = "; ") else v) 489 | data.frame(b$event, event_url=b$event_url, stringsAsFactors = FALSE) 490 | }) 491 | list(events_url=y$events_url, events=eventsdat, csl=y$events_csl) 492 | } 493 | } else if(y$name == "copernicus"){ 494 | if(length(y$events)==0){paste(sorry)} else 495 | { 496 | y$events 497 | } 498 | } else if(y$name == "articlecoverage"){ 499 | if(length(y$events)==0){paste(sorry)} else 500 | { 501 | ev <- do.call(rbind.fill, lapply(y$events, function(y){ 502 | y[sapply(y, is.null)] <- NA 503 | data.frame(y, stringsAsFactors = FALSE) 504 | })) 505 | csl <- ldply(y$events_csl, parse_csl) 506 | list(events_url=y$events_url, events=ev, csl=y$events_csl) 507 | } 508 | } else if(y$name == "articlecoveragecurated"){ 509 | if(length(y$events)==0){paste(sorry)} else 510 | { 511 | ev <- do.call(rbind.fill, lapply(y$events, function(b){ 512 | tmp <- b$event 513 | tmp[sapply(tmp, length)==0|sapply(tmp, is.null)] <- NA 514 | data.frame(tmp, 515 | event_time=b$event_time, 516 | event_url=if(!is.null(b$event_url)) b$event_url else NA, 517 | stringsAsFactors = FALSE) 518 | })) 519 | csl <- ldply(y$events_csl, parse_csl) 520 | list(events_url=y$events_url, events=ev, csl=csl) 521 | } 522 | } else if(y$name == "plos_comments"){ 523 | if(length(y$events)==0){paste(sorry)} else 524 | { 525 | eventsdat <- lapply(y$events, function(b){ 526 | tmp <- b$event 527 | tmp[sapply(tmp, length)==0] <- NA 528 | tmp$replies <- NULL 529 | list(comment=data.frame(tmp, 530 | event_time=b$event_time, 531 | event_url=if(!is.null(b$event_url)) b$event_url else NA, stringsAsFactors = FALSE), 532 | replies=b$event$replies) 533 | }) 534 | csl <- ldply(y$events_csl, parse_csl) 535 | list(events_url=y$events_url, events=y$events, csl=csl) 536 | } 537 | } else if(y$name == "twitter_search"){ 538 | if(length(y$events)==0){paste(sorry)} else 539 | { 540 | y$events 541 | } 542 | } else if(y$name == "doi_resolution"){ 543 | if(length(y$events)==0){paste(sorry)} else 544 | { 545 | y$events 546 | } 547 | } else if(y$name == "orcid"){ 548 | if(length(y$events)==0){paste(sorry)} else 549 | { 550 | y$events 551 | } 552 | } 553 | } 554 | 555 | # Run the parsers on each element 556 | datout <- lapply(x, parsers) 557 | # Assign names to each list element 558 | names(datout) <- if(is.null(label)) sapply(events[[1]], "[[", "name") else label 559 | return( datout ) 560 | } 561 | 562 | # Actually get the events data 563 | tmpout <- lapply(events, getevents, label=source_id) 564 | # byid <- names(almcompact(list(doi=doi, pmid=pmid, pmcid=pmcid, wos=wos, scp=scp, url=url, source_id=source_id, publisher_id=publisher_id))) 565 | byid <- names(almcompact(list(doi=doi, pmid=pmid, pmcid=pmcid, wos=wos, scp=scp, url=url))) 566 | if(length(byid) == 0) byid <- "" 567 | nmz <- if(byid == "") { 568 | NULL 569 | } else if(!byid == 'doi') { 570 | id[[1]] 571 | } else { 572 | if(length(id[[1]]) > 15) { 573 | vapply(ttt, "[[", character(1), "id") 574 | } else { 575 | vapply(ttt$data, "[[", character(1), "id") 576 | } 577 | } 578 | setNames(tmpout, nmz) 579 | } 580 | safe_parse_events <- plyr::failwith(NULL, parse_events) 581 | finaldata <- safe_parse_events() 582 | if(length(finaldata) > 1){ 583 | lapply(finaldata, compact_events) 584 | } else { 585 | compact_events(finaldata[[1]]) 586 | } 587 | } 588 | 589 | compact_events <- function(x){ 590 | phrases <- c("sorry, no events content yet","parser not written yet") 591 | keep <- sapply(x, function(y) if(any(phrases %in% y)) FALSE else TRUE) 592 | x[keep] 593 | } 594 | 595 | try_date_parts <- function(w){ 596 | tmp <- if(is.null(w[['date-parts']])) w[['date_parts']] else w[['date-parts']] 597 | paste(unlist(tmp), collapse="-") 598 | } 599 | 600 | parse_csl <- function(z){ 601 | z[sapply(z, is.null)] <- NA 602 | aut <- paste(sapply(z$author, function(zz) paste(zz, collapse = " ")), collapse = "; ") 603 | data.frame(csl_authors = aut, 604 | csl_title = z$title, 605 | csl_container_title = z$`container-title`, 606 | csl_issued = try_date_parts(z$issued), 607 | csl_url = z$url, 608 | csl_type = z$type, 609 | stringsAsFactors = FALSE) 610 | } 611 | 612 | idtype <- function(x){ 613 | x <- x[ !x %in% c("source_id","publisher_id") ] 614 | if(length(x) == 0){ 615 | NULL 616 | } else { 617 | if( x %in% c("doi", "pmid", "pmcid", "wos", "scp", "url") ) x else NULL 618 | } 619 | } 620 | 621 | delsp <- function(x){ 622 | x[ !names(x) %in% c("source_id","publisher_id") ] 623 | } 624 | --------------------------------------------------------------------------------