diff --git a/.Rbuildignore b/.Rbuildignore new file mode 100644 index 0000000..14c0ace --- /dev/null +++ b/.Rbuildignore @@ -0,0 +1,8 @@ +^codecov\.yml$ +^\.travis\.yml$ +^appveyor\.yml$ +^LICENSE\.md$ +^blah\.Rproj$ +^\.Rproj\.user$ +^README\.Rmd$ +^.*\.Rproj$ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8e3a7fd --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +inst/doc +.Rproj.user diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..b882586 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,17 @@ +language: R +sudo: no +cache: packages +after_success: if [ "$TRAVIS_OS_NAME" == "linux" ]; then Rscript -e 'covr::codecov(type + = "all")'; fi +warnings_are_errors: yes +before_deploy: if [ "$TRAVIS_OS_NAME" == "osx" ]; then rm -f *.tar.gz; fi +r_check_args: --as-cran --install-args=--build +deploy: + provider: releases + skip_cleanup: yes + file_glob: yes + file: blah*.t*gz + 'on': + tags: yes + repo: muschellij2/blah + diff --git a/DESCRIPTION b/DESCRIPTION new file mode 100644 index 0000000..7f979b0 --- /dev/null +++ b/DESCRIPTION @@ -0,0 +1,31 @@ +Type: Package +Package: bibliometRics +Title: Bibliometric Analysis of Scientific Production +Version: 0.1.0 +Authors@R: + c( + person(given ="Santiago", family = "Beguería", + role = c("aut", "cre"), + email = "santiago.begueria@csic.es", + comment = c(ORCID = "0000-0002-3974-2947")), + person(given = "John", + family = "Muschelli", + role = c("aut"), + email = "muschellij2@gmail.com", + comment = c(ORCID = "0000-0001-6469-1750")) + ) +Description: Analyzes the production of a single author, a + working team, or department from the perspective of citations. +License: GPL-3 +Imports: + utils, + graphics +Suggests: + covr, + knitr, + rmarkdown, + testthat +Encoding: UTF-8 +LazyData: true +VignetteBuilder: knitr +RoxygenNote: 6.1.0 diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 9cecc1d..0000000 --- a/LICENSE +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - {one line to give the program's name and a brief idea of what it does.} - Copyright (C) {year} {name of author} - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - {project} Copyright (C) {year} {fullname} - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/NAMESPACE b/NAMESPACE new file mode 100644 index 0000000..49cd52f --- /dev/null +++ b/NAMESPACE @@ -0,0 +1,15 @@ +# Generated by roxygen2: do not edit by hand + +export(bibliometric) +export(biblioplot) +export(biblioplot2) +export(citation_rank) +export(egghe) +export(format_pub) +export(hirsch) +export(ifactor) +export(read.baselines) +export(read.wos) +import(graphics) +importFrom(tools,toTitleCase) +importFrom(utils,read.table) diff --git a/NEWS.md b/NEWS.md new file mode 100644 index 0000000..47083ab --- /dev/null +++ b/NEWS.md @@ -0,0 +1,3 @@ +# blah 0.1.0 + +* Added a `NEWS.md` file to track changes to the package. diff --git a/R/bibliometRics.R b/R/bibliometRics.R new file mode 100644 index 0000000..665d66a --- /dev/null +++ b/R/bibliometRics.R @@ -0,0 +1,182 @@ + + + + +# read.scopus <- function(infile) { + + # # author + # au <- read.table(infile,sep=',',nrows=1,stringsAsFactors=FALSE)[,2] + # au <- substr(au,9,nchar(au)) + + # # read publications + # dat <- read.table(infile,sep=',',stringsAsFactors=FALSE,skip=7)[,c(1:7,9,12)] + # colnames(dat) <- c('year','title','authors','issn','journal','volume','issue','cit','cittotal') + + # return() +# } +# bib <- read.scopus('scopus_SBP_win.csv') + + +#' Calculate Bibliometrics +#' +#' @param bib A list with an element called \code{pubs}, which is a +#' \code{data.frame} with columns \code{'Publication Year'} and +#' \code{'Total Citations'}. Usually +#' from \code{\link{read.wos}} +#' @param base Baseline percentages +#' @param discipline Name of Discipline, must be in column names of +#' \code{base} +#' +#' @return A \code{data.frame} of metric +#' @export +#' +#' @examples +#' wos_file = system.file("sbegueria.txt", package = "bibliometRics") +#' bib <- read.wos(wos_file) +#' bib$author = gsub('[ñÑ]', 'N', bib$author) +#' bib$pubs$Authors = gsub('[ñÑ]', 'N', bib$pubs$Authors) +#' +#' base = read.baselines() +#' discipline = 'GEOSCIENCES' +#' bibliometric(bib, base, 'GEOSCIENCES') +bibliometric <- + function(bib, + base = read.baselines(), + discipline = NULL) { + if (!is.null(discipline)) { + w <- grep(discipline, names(base)) + } else { + w <- 1 + } + quant <- base[[w]] + + au <- bib$author + dat <- bib$pubs + + # publications + pubs <- nrow(dat) + + # publications as lead author + leads <- + as.character(lapply(dat[, 'Authors'], function(x) { + strsplit(x, ';')[[1]][1] + })) + auu <- strsplit(au, ',')[[1]][1] + pubs_lead <- grep(auu, leads, ignore.case = TRUE) + # pubs_lead <- length(grep(auu,leads,ignore.case=TRUE)) + + # impact factor + ifact2 <- round(ifactor(bib, n = 2), 2) + ifact5 <- round(ifactor(bib, n = 5), 2) + + # citations + cit_tot <- sum(dat[, 'Total Citations']) + cit_max <- max(dat[, 'Total Citations']) + cit_art <- round(mean(dat[, 'Total Citations']), 2) + ini <- min(dat[, 'Publication Year']) + span <- max(dat[, 'Publication Year']) - ini + + # number of pubs with n citations + icit <- function(x, n = 10) { + length(which(x[, 'Total Citations'] >= n)) + } + i10 <- icit(dat) + i25 <- icit(dat, 25) + i50 <- icit(dat, 50) + + # h-index + hin <- hirsch(bib) + + # g-index + gin <- egghe(bib) + + # pubs >0.9, >0.99 + r <- citation_rank(bib, quant = quant) + p09 <- sum(as.numeric(r) <= 4, na.rm = TRUE) + p099 <- sum(as.numeric(r) <= 3, na.rm = TRUE) + + # pubs >0.9, as lead author + r_lead <- citation_rank(bib, pubs_lead, quant) + p09_lead <- sum(as.numeric(r_lead) <= 4, na.rm = TRUE) + + # i-score + scores <- + c(1 / (1 - 0.9999), + 1 / (1 - 0.999), + 1 / (1 - 0.99), + 1 / (1 - 0.9), + 1 / (1 - 0.8), + 1 / (1 - 0.5), + 1 / 1) + iscore <- sum(scores[as.numeric(r)], na.rm = TRUE) + + # i-score, as lead author + isc_lead <- sum(scores[as.numeric(r_lead)], na.rm = TRUE) + + # output + out <- as.data.frame(t( + c( + name = au, + ini, + span, + pubs, + length(pubs_lead), + round(pubs / span, 2), + hin, + round(hin / span, 2), + gin, + round(gin / span, 2), + cit_tot, + round(cit_tot / span, 2), + cit_art, + ifact2, + ifact5, + i10, + i25, + i50, + cit_max, + p09, + p09_lead, + p099, + round(iscore, 2), + round(isc_lead, 2) + ) + )) + colnames(out) <- + c( + 'name', + 'ini', + 'years', + 'pubs', + 'lead', + 'pubs_year', + 'hin', + 'hin_year', + 'gin', + 'gin_year', + 'cit_tot', + 'cit_year', + 'cit_art', + 'ifact2', + 'ifact5', + 'i10', + 'i25', + 'i50', + 'cit_max', + 'pubs09', + 'pubs09_lead', + 'pubs099', + 'iscore', + 'iscore_lead' + ) + return(out) + } +#bibliometric(bib, baseline) + + + + + + + + diff --git a/R/citation_rank.R b/R/citation_rank.R new file mode 100644 index 0000000..d3ec77b --- /dev/null +++ b/R/citation_rank.R @@ -0,0 +1,58 @@ + +#' Calculate citation ranking (quantiles) +#' +#' @param x A list with an element called \code{pubs}, which is a +#' \code{data.frame} with columns \code{'Publication Year'} and +#' \code{'Total Citations'}. Usually +#' from \code{\link{read.wos}} +#' @param w column indicators of which quantiles to grab +#' @param quant A \code{data.frame}? maybe +#' +#' @return A scalar number +#' @export +#' +#' @examples +#' wos_file = system.file("sbegueria.txt", package = "bibliometRics") +#' bib <- read.wos(wos_file) +#' hirsch(bib) +#' hirsch(bib, 2010) +#' egghe(bib) +#' egghe(bib, 2010) +#' base = read.baselines() +#' citation_rank(bib, quant=base$GEOSCIENCES) +citation_rank <- function(x, w = NULL, quant = NULL) { + x <- x$pubs + if (!is.null(w)) { + x <- x[w, ] + } + r <- + data.frame(a = x[, 'Publication Year'], + b = x[, 'Total Citations'], + c = '', + stringsAsFactors = FALSE) + r$c <- + factor(r$c, + levels = c( + '>q0.9999', + '>q0.999', + '>q0.99', + '>q0.9', + '>q0.8', + '>q0.5', + '>q0' + )) + for (i in 1:nrow(r)) { + w <- grep(r[i, 1], names(quant)) + if (length(w) == 0) + next() + ww <- which(r[i, 2] - quant[, w] >= 0)[1] + if (is.na(ww)) { + r[i, 3] <- levels(r$c)[7] + } else { + r[i, 3] <- levels(r$c)[ww] + } + } + return(r[, 3]) +} +#citation_rank(bib, c(9,10), quant) +#citation_rank(bib, quant) diff --git a/R/format_pub.R b/R/format_pub.R new file mode 100644 index 0000000..0459a62 --- /dev/null +++ b/R/format_pub.R @@ -0,0 +1,90 @@ +#' Format Publication data +#' +#' @param x A list with an element called \code{pubs}, which is a +#' \code{data.frame} with columns \code{'Publication Year'} and +#' \code{'Total Citations'}. Usually +#' from \code{\link{read.wos}} +#' @param au Author to grab publications +#' @importFrom tools toTitleCase +#' @return A character vector +#' @export +#' @examples +#' wos_file = system.file("sbegueria.txt", package = "bibliometRics") +#' bib <- read.wos(wos_file) +#' base = read.baselines() +#' au = bib$au +#' au = gsub('Ñ', 'N', au) +#' format_pub(cbind(bib$pubs, +#' citation_rank(bib,quant=base$GEOSCIENCES))[1,], +#' au=au) +format_pub <- function(x, au) { + # format authors + if (substr(x['Authors'], nchar(x['Authors']), nchar(x['Authors'])) != '.') { + x['Authors'] <- paste(x['Authors'], '.', sep = '') + } + auths <- strsplit(as.character(x['Authors']), ';')[[1]] + w <- + grep(strsplit(au, ',')[[1]][1], auths, ignore.case = TRUE) + auths[w] <- paste('\\textbf{', auths[w], '}', sep = '') + auths <- paste0(auths, sep = ';', collapse = '') + auths <- substr(auths, 1, nchar(auths) - 1) + # format citations rank + w <- grep('rank', names(x)) + # if (is.na(x[,w]) | x[,w]=='') { + if (is.na(x[w])) { + rank <- '' + } else { + # rank <- paste('; $',x[,w],'$',sep='') + rank <- paste('; $', x[w], '$', sep = '') + } + # format title + title <- + gsub('&', '\\\\&', toTitleCase(tolower(as.character(x['Title'])))) + # format source + source <- gsub('&', '\\\\&', x['Source Title']) + # format volume and pages + if (is.na(x['Volume'])) { + vol <- '' + } else { + vol <- paste(' ', x['Volume'], sep = '') + } + if (is.na(x['Issue']) | x['Issue'] == '') { + issue <- '' + } else { + issue <- paste('(', x['Issue'], ')', sep = '') + } + if (is.na(x['Beginning Page']) | x['Beginning Page'] == '' | + is.na(x['Ending Page']) | x['Ending Page'] == '') { + if (is.na(x['Article Number']) | x['Article Number'] == '') { + pages <- '' + } else { + pages <- paste(': ', x['Article Number'], sep = '') + } + } else { + pages <- + paste(': ', x['Beginning Page'], '--', x['Ending Page'], sep = '') + } + # put everything together + string = paste( + '\\item ', + auths, + ' ', + title, + '. ', + '\\textit{', + source, + '}', + vol, + issue, + pages, + '. ', + x['Publication Year'], + '. ', + '(cit: ', + x['Total Citations'], + rank, + ')\n', + sep = '' + ) + return(string) +} diff --git a/R/hirsch.R b/R/hirsch.R new file mode 100644 index 0000000..63300ec --- /dev/null +++ b/R/hirsch.R @@ -0,0 +1,73 @@ + +#' Calculate Hirsch's h-index or Egghe's g-index +#' +#' @param bib A list with an element called \code{pubs}, which is a +#' \code{data.frame} with column \code{'Publication Year'}. Usually +#' from \code{\link{read.wos}} +#' @param year Maximum year to include for calculation +#' +#' @return A scalar number +#' @export +#' +#' @examples +#' wos_file = system.file("sbegueria.txt", package = "bibliometRics") +#' bib <- read.wos(wos_file) +#' hirsch(bib) +#' hirsch(bib, 2010) +#' egghe(bib) +#' egghe(bib, 2010) +#' ifactor(bib) # 2-year impact factor +#' ifactor(bib,2013) # 2-year impact factor, year 2013 +#' ifactor(bib,n=5) # 5-year impact factor#' +hirsch <- function(bib, year = NULL) { + x <- bib$pubs + if (is.null(year)) { + #y <- max(x[,'Publication Year']) + year <- rev(colnames(x))[1] + } + w <- which(x[, 'Publication Year'] <= year) + ww <- which(colnames(x) <= year) + if (length(ww) > 1) { + cit <- rowSums(x[w, ww]) + } else { + cit <- x[w, ww] + } + #cit <- x[,'Total Citations'] + hin <- cbind(cit[order(cit, decreasing = TRUE)], 1:length(cit)) + w <- (hin[, 1] - hin[, 2]) > 0 + if (sum(w) == 0) + return(0) + return(max(hin[w, 2])) +} + + +#' @export +#' @rdname hirsch +egghe <- function(bib, year = NULL) { + x <- bib$pubs + if (is.null(year)) { + year <- max(x[, 'Publication Year']) + } + w <- x[, 'Publication Year'] <= year + cit <- x[w, 'Total Citations'] + gin <- cbind(1:length(cit), + cumsum(cit[order(cit, decreasing = TRUE)]), + (1:length(cit)) ^ 2) + w <- (gin[, 2] - gin[, 3]) > 0 + return(max(gin[w, 1])) +} + + +#' @export +#' @rdname hirsch +#' @param n number of years +ifactor <- function(bib, year = NULL, n = 2) { + x <- bib$pubs + all_years <- x[, 'Publication Year'] + if (is.null(year)) { + year <- max(all_years, na.rm = TRUE) - 1 + } + w <- which(all_years >= (year - n) & all_years < year) + ww <- which(colnames(x) == year) + sum(x[w, ww]) / length(w) +} diff --git a/R/plot.R b/R/plot.R new file mode 100644 index 0000000..7858716 --- /dev/null +++ b/R/plot.R @@ -0,0 +1,248 @@ +#' Plot Bibliometrics +#' +#' @param bib A list with an element called \code{pubs}, which is a +#' \code{data.frame} with columns \code{'Publication Year'} and +#' \code{'Total Citations'}. Usually +#' from \code{\link{read.wos}} +#' @param quant Quantile, passed to \code{\link{citation_rank}} +#' +#' @return NULL +#' @export +#' +#' @import graphics +#' +#' @examples +#' wos_file = system.file("sbegueria.txt", package = "bibliometRics") +#' bib <- read.wos(wos_file) +#' base = read.baselines() +#' biblioplot(bib, q=base$GEOSCIENCES) +#' bib$author = gsub('Ñ', 'N', bib$author) +biblioplot <- function(bib, quant) { + opar = par(no.readonly = TRUE) + on.exit({ + par(opar) + }) + par(mfrow = c(1, 3)) + + au <- bib$author + dat <- bib$pubs + + # Publication range + pubrange <- range(dat[, 'Publication Year']) + + # Leading authors + leads <- + as.character(lapply(dat[, 'Authors'], function(x) { + strsplit(x, ';')[[1]][1] + })) + w_lead <- + grep(strsplit(au, ',')[[1]][1], leads, ignore.case = TRUE) + + # Publications and citations + # pubs per year + years <- dat[, 'Publication Year'] + years <- factor(years, levels = as.character(min(years):max(years))) + years_nolead <- years[-w_lead] + years_lead <- years[w_lead] + pubs <- rbind(table(years_lead), table(years_nolead)) + rownames(pubs) <- c('pubs_lead', 'pubs_nolead') + # cumulative pubs + pubs_cum <- t(apply(pubs, 1, cumsum)) + # citations per year + cits_lead <- + t(as.matrix(colSums(bib$pubs[w_lead, 22:ncol(bib$pubs)]))) + cits_nolead <- + t(as.matrix(colSums(bib$pubs[-w_lead, 22:ncol(bib$pubs)]))) + cits <- rbind(cits_lead, cits_nolead) + rownames(cits) <- c('cits_lead', 'cits_nolead') + w <- colnames(cits) >= pubrange[1] & colnames(cits) <= pubrange[2] + cits <- cits[, w] + # cumulative citations + cits_cum <- t(apply(cits, 1, cumsum)) + # plot + par(mar = c(5, 4, 4, 4) + 0.1) + ylabs <- + pretty(c(0, max(max( + colSums(pubs_cum) + ), ceiling(max( + colSums(cits_cum) + ) / 10)))) + ylims <- c(min(ylabs), max(ylabs)) + pubbar <- barplot(pubs_cum, + ylim = ylims, + ylab = '', + yaxt = 'n') + abline(h = ylabs, col = 'lightgray', lty = 'dotted') + par(new = TRUE) + pubbar <- barplot(pubs_cum, + ylim = ylims, + ylab = '', + yaxt = 'n') + lines(x = pubbar, y = cits_cum['cits_lead', ] / 10) + points(x = pubbar, y = cits_cum['cits_lead', ] / 10, pch = 19) + lines(x = pubbar, y = colSums(cits_cum) / 10) + points( + x = pubbar, + y = colSums(cits_cum) / 10, + pch = 19, + col = 'lightgray' + ) + points(x = pubbar, + y = colSums(cits_cum) / 10, + pch = 21) + axis(2) + axis(4, at = pretty(ylims), labels = pretty(ylims) * 10) + mtext('Pubs', 2, line = 2.5, cex = 0.75) + mtext('Citations', 4, line = 2.5, cex = 0.75) + + # h- and g-index + years <- + c(min(dat[, 'Publication Year']):max(dat[, 'Publication Year'])) + hh <- NULL + gg <- NULL + for (y in years) { + hh <- c(hh, hirsch(bib, y)) + gg <- c(gg, egghe(bib, y)) + } + # plot + ylabs <- pretty(c(0, max(max(hh), ceiling(max( + gg + ) / 2)))) + ylims <- c(min(ylabs), max(ylabs)) + plot( + x = years, + y = hh, + type = 'n', + ylab = '', + xlab = '', + ylim = ylims + ) + abline(h = pretty(hh), col = 'lightgray', lty = 'dotted') + lines(years, 0:{ + length(years) - 1 + }, lty = 'dashed') + lines(x = years, y = hh) + points(x = years, y = hh, pch = 19) + mtext('h-index', 2, line = 2.5, cex = 0.75) + par(new = TRUE) + lines(x = years, y = gg / 2) + points( + x = years, + y = gg / 2, + pch = 19, + col = 'lightgray' + ) + points(x = years, y = gg / 2, pch = 21) + axis(4, at = pretty(ylims), labels = pretty(ylims) * 2) + mtext('g-index', 4, line = 2.5, cex = 0.75) + + # Excelence + exc <- + rbind(rev(table( + citation_rank(bib, w_lead, quant = quant) + )), rev(table( + citation_rank(bib,-w_lead, quant = quant) + )))[, -7] + rownames(exc) <- c('pubs_lead', 'pubs_nolead') + # plot + barplot(exc) + abline(h = pretty(colSums(exc)), + col = 'lightgray', + lty = 'dotted') + par(new = TRUE) + barplot(exc) + mtext('Counts', 2, line = 2.5, cex = 0.75) +} +#biblioplot(bib) + +#' @rdname biblioplot +#' @export +biblioplot2 <- function(bib) { + opar = par(no.readonly = TRUE) + on.exit({ + par(opar) + }) + par(mfrow = c(1, 2)) + + au <- bib$author + dat <- bib$pubs + + # Publication range + pubrange <- range(dat[, 'Publication Year']) + + # Leading authors + leads <- + as.character(lapply(dat[, 'Authors'], function(x) { + strsplit(x, ';')[[1]][1] + })) + + # Publications and citations + # pubs per year + years <- dat[, 'Publication Year'] + years <- factor(years, levels = as.character(min(years):max(years))) + pubs <- table(years) + # cumulative pubs + pubs_cum <- cumsum(pubs) + # citations per year + cits <- t(as.matrix(colSums(bib$pubs[, 22:ncol(bib$pubs)]))) + rownames(cits) <- c('cits') + w <- colnames(cits) >= pubrange[1] & colnames(cits) <= pubrange[2] + cits <- cits[, w] + # cumulative citations + cits_cum <- cumsum(cits) + # plot + par(mar = c(5, 4, 4, 4) + 0.1) + ylabs <- pretty(c(0, max(max(pubs_cum), ceiling(max( + cits_cum + ) / 10)))) + ylims <- c(min(ylabs), max(ylabs)) + pubbar <- barplot(pubs_cum, + ylim = ylims, + ylab = '', + yaxt = 'n') + abline(h = ylabs, col = 'lightgray', lty = 'dotted') + par(new = TRUE) + pubbar <- barplot(pubs_cum, + ylim = ylims, + ylab = '', + yaxt = 'n') + lines(x = pubbar, y = cits_cum / 10) + points(x = pubbar, y = cits_cum / 10, pch = 19) + axis(2) + axis(4, at = pretty(ylims), labels = pretty(ylims) * 10) + mtext('Pubs', 2, line = 2.5, cex = 0.75) + mtext('Citations', 4, line = 2.5, cex = 0.75) + title('Publications and citations') + + # h-index + years <- + c(min(dat[, 'Publication Year']):max(dat[, 'Publication Year'])) + hh <- NULL + for (y in years) { + hh <- c(hh, hirsch(bib, y)) + gg <- c(gg, egghe(bib, y)) + } + # plot + ylabs <- pretty(c(0, max(max(hh)))) + ylims <- c(min(ylabs), max(ylabs)) + plot( + x = years, + y = hh, + type = 'n', + ylab = '', + xlab = '', + ylim = ylims + ) + abline(h = pretty(hh), col = 'lightgray', lty = 'dotted') + lines(years, 0:{ + length(years) - 1 + }, lty = 'dashed') + lines(x = years, y = hh) + points(x = years, y = hh, pch = 19) + mtext('h-index', 2, line = 2.5, cex = 0.75) + title('h-index') + return(invisible(NULL)) +} + + + diff --git a/R/read.baselines.R b/R/read.baselines.R new file mode 100644 index 0000000..2c80d5b --- /dev/null +++ b/R/read.baselines.R @@ -0,0 +1,33 @@ +#' Read field percentile baselines (FPB) from the Essential Science +#' Indicators database. +#' +#' @param infile Baseline percentages for each field +#' +#' @importFrom utils read.table +#' @return A \code{list} of percentages +#' @export +#' +#' @examples +#' res = read.baselines() +read.baselines <- + function(infile = system.file("BaselinePercentiles.csv", + package = "bibliometRics")) { + fpb <- read.table( + infile, + sep = ',', + skip = 1, + stringsAsFactors = FALSE, + header = TRUE + ) + + # \u00A9 is © + fields <- fpb$RESEARCH.FIELDS[-grep('%|\u00A9', fpb$RESEARCH.FIELDS)] + baselines <- list(NULL) + for (i in 1:length(fields)) { + w <- which(fpb$RESEARCH.FIELDS == fields[i]) + baselines[[i]] <- fpb[w + 1:6, ] + colnames(baselines[[i]])[1] <- 'percentiles' + names(baselines)[i] <- fields[i] + } + return(baselines) + } diff --git a/R/read.wos.R b/R/read.wos.R new file mode 100644 index 0000000..8e7813a --- /dev/null +++ b/R/read.wos.R @@ -0,0 +1,35 @@ +# Functions to read and process Web of Science citation report data. +#bib <- read.isiwok('isiwok_MAM.txt') + +#' Read and process Web of Science citation report data. +#' +#' @param infile Input text file from Web of Science +#' +#' @return A list of information +#' @export +#' @examples +#' wos_file = system.file('sbegueria.txt', package = "bibliometRics") +#' bib <- read.wos(wos_file) +read.wos <- function(infile) { + + # author + au <- read.table(infile, sep=',', nrows=1, stringsAsFactors=FALSE) + #au <- paste(gsub('AUTHOR: \\(','',au[1]),gsub('\\)','',au[2]),sep=', ') + au <- paste(gsub('(AUTHOR)( IDENTIFIERS)*(: \\()','',au[1]), gsub('\\)','',au[2]),sep=', ') + au <- toupper(au) + + # reference + re <- gsub('.txt','',rev(strsplit(infile,'/')[[1]])[1]) + + # read publications + nskip <- ifelse (read.table(infile,sep=',',nrows=1,skip=1)=='null', 5, 4) + dat <- read.table(infile, sep=',', stringsAsFactors=FALSE, skip=nskip) + colnames(dat) <- read.table(infile,sep=',',stringsAsFactors=FALSE,skip=nskip-1,nrows=1) + o <- rev(order(dat[,'Publication Year'])) + dat <- dat[o,] + start <- min(dat[,'Publication Year']) + w <- which(colnames(dat)==start) + dat <- dat[,c(1:21,w:ncol(dat))] + + return(list(author=au,reference=re,pubs=dat)) +} diff --git a/README.Rmd b/README.Rmd new file mode 100644 index 0000000..4ba3a75 --- /dev/null +++ b/README.Rmd @@ -0,0 +1,353 @@ +--- + output: github_document +--- + +[![Travis build status](https://travis-ci.com/sbegueria/bibliometRics.svg?branch=master)](https://travis-ci.com/sbegueria/bibliometRics) +[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/sbegueria/bibliometRics?branch=master&svg=true)](https://ci.appveyor.com/project/sbegueria/bibliometRics) +[![Coverage status](https://codecov.io/gh/sbegueria/bibliometRics/branch/master/graph/badge.svg)](https://codecov.io/gh/sbegueria/bibliometRics) + + +```{r setup, include = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>", + fig.path = "man/figures/README-" +) +``` + + + + +# bibliometRics [![DOI](https://zenodo.org/badge/57246514.svg)](https://zenodo.org/badge/latestdoi/57246514) + +Santiago Beguería +26 April 2016 + +`bibliometRics` is an R package for bibliometric analysis of scientific +production. It can be used for analysing the production of a single +author, a working team, department, institute, etcetera. + +This document describes the main functionalities in the package, and how +to do a bibliometric analysis with `bibliometRics`, including producing +automatic pdf reports via `knitr`. + +You can cite this package on your work as: **Beguería S. (2015) +bibliometRics: an R package for for bibliometric analysis of scientific +production, **. + +## Installation + +You can install this version of GitHub (note that this is a working +project): + +``` r +devtools::install_github("sbegueria/bibliometRics") +``` + +## Getting some bibliometric data + +So far the unique source of blibiometric information accepted by +`bibliometRics` is the Web of Science (WoS) by Thomson Reuters, but +other sources such as Scopus or Google Scholar can be added in the +future. Publications can be selected for a given author (easiest if you +know its author ID) or a group (such a research group or a department, +for instance). The WoS allows to generate a citation report, stating the +number of citations received by each item, every year after its +publication. So once you are good with the selection of publications you +want to analyze, you can click on the ‘create citation report’ button +and then select the ‘save to text file’ option. This will generate a +text file and download it to your computer. You may want to edit the +AUTHOR field on the first line of this text file, although this is not +strictly necessary for doing the analysis. + +An example citation report file from the WoS is the file +[sbegueria.txt](sbegueria.txt), which contains data of papers I have +authored, as of January 2017. + +The core function for reading WoS citation report data is, not +surprisingly, `read.wos`. Its only argument is the name of the data file +you want to read: + +``` r +bib <- read.wos('sbegueria.txt') +str(bib) +``` + +``` r +## List of 3 +## $ author : chr "BEGUERIA, SANTIAGO" +## $ reference: chr "sbegueria" +## $ pubs :'data.frame': 88 obs. of 39 variables: +## ..$ Title : chr [1:88] "Estimating erosion rates using Cs-137 measurements and WATEM/SEDEM in a Mediterranean cultivated field" "Recent changes and drivers of the atmospheric evaporative demand in the Canary Islands" "Mid and late Holocene forest fires and deforestation in the subalpine belt of the Iberian range, northern Spain" "Use of disdrometer data to evaluate the relationship of rainfall kinetic energy and intensity (KE-I)" ... +## ..$ Authors : chr [1:88] "Quijano, Laura; Begueria, Santiago; Gaspar, Leticia; Navas, Ana" "Vicente-Serrano, Sergio M.; Azorin-Molina, Cesar; Sanchez-Lorenzo, Arturo; El Kenawy, Ahmed; Martin-Hernandez, Natalia; Pena-Ga"| __truncated__ "Garcia-Ruiz, Jose M.; Sanjuan, Yasmina; Gil-Romera, Graciela; Gonzalez-Samperiz, Penelope; Begueria, Santiago; Arnaez, Jose; Co"| __truncated__ "Angulo-Martinez, M.; Begueria, S.; Kysely, J." ... +## ..$ Corporate Authors: logi [1:88] NA NA NA NA NA NA ... +## ..$ Editors : logi [1:88] NA NA NA NA NA NA ... +## ..$ Book Editors : chr [1:88] "" "" "" "" ... +## ..$ Source Title : chr [1:88] "CATENA" "HYDROLOGY AND EARTH SYSTEM SCIENCES" "JOURNAL OF MOUNTAIN SCIENCE" "SCIENCE OF THE TOTAL ENVIRONMENT" ... +## ..$ Publication Date : chr [1:88] "MAR 2016" "AUG 23 2016" "OCT 2016" "OCT 15 2016" ... +## ..$ Publication Year : int [1:88] 2016 2016 2016 2016 2016 2016 2016 2015 2015 2015 ... +## ..$ Volume : chr [1:88] "138" "20" "13" "568" ... +## ..$ Issue : chr [1:88] "" "8" "10" "" ... +## ..$ Part Number : chr [1:88] "" "" "" "" ... +## ..$ Supplement : logi [1:88] NA NA NA NA NA NA ... +## ..$ Special Issue : chr [1:88] "" "" "" "" ... +## ..$ Beginning Page : int [1:88] 38 3393 1760 83 2120 3413 NA 429 853 773 ... +## ..$ Ending Page : chr [1:88] "51" "3410" "1772" "94" ... +## ..$ Article Number : chr [1:88] "" "" "" "" ... +## ..$ DOI : chr [1:88] "10.1016/j.catena.2015.11.009" "10.5194/hess-20-3393-2016" "10.1007/s11629-015-3763-8" "10.1016/j.scitotenv.2016.05.223" ... +## ..$ Conference Title : chr [1:88] "" "" "" "" ... +## ..$ Conference Date : chr [1:88] "" "" "" "" ... +## ..$ Total Citations : int [1:88] 0 0 0 0 2 2 4 0 4 4 ... +## ..$ Average per Year : num [1:88] 0 0 0 0 1 1 2 0 1.33 1.33 ... +## ..$ 2000 : int [1:88] 0 0 0 0 0 0 0 0 0 0 ... +## ..$ 2001 : int [1:88] 0 0 0 0 0 0 0 0 0 0 ... +## ..$ 2002 : int [1:88] 0 0 0 0 0 0 0 0 0 0 ... +## ..$ 2003 : int [1:88] 0 0 0 0 0 0 0 0 0 0 ... +## ..$ 2004 : int [1:88] 0 0 0 0 0 0 0 0 0 0 ... +## ..$ 2005 : int [1:88] 0 0 0 0 0 0 0 0 0 0 ... +## ..$ 2006 : int [1:88] 0 0 0 0 0 0 0 0 0 0 ... +## ..$ 2007 : int [1:88] 0 0 0 0 0 0 0 0 0 0 ... +## ..$ 2008 : int [1:88] 0 0 0 0 0 0 0 0 0 0 ... +## ..$ 2009 : int [1:88] 0 0 0 0 0 0 0 0 0 0 ... +## ..$ 2010 : int [1:88] 0 0 0 0 0 0 0 0 0 0 ... +## ..$ 2011 : int [1:88] 0 0 0 0 0 0 0 0 0 0 ... +## ..$ 2012 : int [1:88] 0 0 0 0 0 0 0 0 0 0 ... +## ..$ 2013 : int [1:88] 0 0 0 0 0 0 0 0 0 0 ... +## ..$ 2014 : int [1:88] 0 0 0 0 0 0 0 0 0 0 ... +## ..$ 2015 : int [1:88] 0 0 0 0 0 0 0 0 0 1 ... +## ..$ 2016 : int [1:88] 0 0 0 0 2 2 4 0 4 3 ... +## ..$ 2017 : int [1:88] 0 0 0 0 0 0 0 0 0 0 ... +``` + +The result is a list with the following three elements: \* `author`, a +character object with the name of the author being analysed; \* +`reference`, a character object; and \* `pubs`, a data frame with the +publications in rows, and the data referring to each publications in +columns, including the number of citations received, year by year. + +## Analyzing bibliometric data + +The main function for analyizing these data is `bibliometric`. It takes +an object with the bibliometric data resulting from a call to `read.wos` +and returns a data.frame with a number of bibliometric indices. + +In order to compute some metrics which are based on the number of +citations received by each publication, data on the percentile baselines +for each scientific discipline is requireed. This data can be found on +another Thomson Reuters product, the ‘Essential Science Indicators’ +database. You need to navigate to the ‘Field Baselines’ tab, and then +select ‘Percentiles’ to get the field percentile baselines (FPB). You +can then download the FPB table in csv format. + +An example FPB table as of January 2017 can be found in file +[BaselinePercentiles.csv](BaselinePercentiles.csv). This table can be +read with the function ‘read.baselines’: + +``` r +base <- read.baselines('BaselinePercentiles.csv') +``` + +The resulting object is a list with as many items as disciplines. For +each discipline, a data.frame is stored containing the threshold number +of citations corresponding to each percentile, depending on the +publication year. For instance, this is are the baseline thresholds for +the discipline ‘Geosciences’: + +``` r +base$GEOSCIENCES +``` + +We can now use the function `bibliometric`, especifying the, the field +baselines, and the discipline (the table for ‘all fields’ will be used +as a default if no discipline is specified). + +``` r +bibliometric(bib, base, 'GEOSCIENCES') +``` + +``` r +## name ini years pubs lead pubs_year hin hin_year +## 1 BEGUERIA, SANTIAGO 2000 16 88 17 5.5 33 2.06 +## gin gin_year cit_tot cit_year cit_art ifact2 ifact5 i10 i25 i50 +## 1 57 3.56 3472 217 39.45 15.43 14.13 65 48 16 +## cit_max pubs09 pubs09_lead pubs099 iscore iscore_lead +## 1 616 32 7 11 4145 187 +``` + +These are the +following: + +| Label | Meaning | +| ------------ | --------------------------------------------------------------------------------- | +| name | Name of the author, group, department, etc. | +| ini | Initial year of the publication record | +| span | Time span (years) of the publication record | +| pubs | Total number of publications | +| lead | Total number of publications, as the lead (first) author | +| pubs\_year | Mean number of publications per year | +| hin | Hirsch’s h-index | +| hin\_year | h-index per year | +| gin | Egghe’s g-index | +| gin\_year | g-index per year | +| cit\_tot | Total number of citations | +| cit\_year | Mean number of citations per year | +| cit\_art | Mean number of citations per article | +| ifact2 | Impact factor, computed over the last two years | +| ifact5 | Impact factor, computed over the last five years | +| i10 | Number of publications with 10 or more citations | +| i25 | Number of publications with 25 or more citations | +| i50 | Number of publications with 50 or more citations | +| cit\_max | Number of citations of the most citated publications | +| pubs09 | Number of publications over the 90th percentile in its discipline | +| pubs09\_lead | Number of publications over the 90th percentile in its discipline, as lead author | +| pubs099 | Number of publications over the 99th percentile in its discipline | +| iscore | i-score | +| iscore\_lead | i-score, as lead author | + +There are functions for computing some of the indices, such as the +Hirsch and the Egghe indices. These can be computed for the whole period +analyized, or up to a given year. + +``` r +hirsch(bib) +``` + +``` r +## [1] 33 +``` + +``` r +egghe(bib) +``` + +``` r +## [1] 57 +``` + +``` r +hirsch(bib, 2010) +``` + +``` r +## [1] 13 +``` + +``` r +egghe(bib, 2010) +``` + +``` r +## [1] 45 +``` + +There is also a function for ranking the publications in quantiles: + +``` r +rank(bib, q=base$GEOSCIENCES) +``` + +``` r +## [1] >q0 >q0 >q0 >q0 >q0.9 >q0.9 >q0.99 >q0 +## [9] >q0.8 >q0.8 >q0.9 >q0.9 >q0.99 >q0.99 >q0.99 >q0.999 +## [17] >q0 >q0.99 >q0.99 >q0.5 >q0.9 >q0.9 >q0.999 >q0 +## [25] >q0 >q0.5 >q0.5 >q0.8 >q0.8 >q0.9 >q0.9 >q0.9 +## [33] >q0 >q0 >q0.5 >q0.5 >q0.8 >q0.8 >q0.8 >q0.8 +## [41] >q0.9 >q0.9 >q0.99 >q0 >q0 >q0.5 >q0.8 >q0.9 +## [49] >q0.9 >q0.9 >q0.9 >q0.9 >q0.99 >q0.999 >q0.5 >q0.5 +## [57] >q0.8 >q0.8 >q0.8 >q0.8 >q0.8 >q0.9 >q0.9 >q0 +## [65] >q0.5 >q0.8 >q0.8 >q0.8 >q0.8 >q0.5 >q0.5 >q0.8 +## [73] >q0.8 >q0.9 >q0.9 >q0.9 +## [81] +## Levels: >q0.9999 >q0.999 >q0.99 >q0.9 >q0.8 >q0.5 >q0 +``` + +``` r +table(rank(bib, q=base$GEOSCIENCES)) +``` + +``` r +## >q0.9999 >q0.999 >q0.99 >q0.9 >q0.8 >q0.5 >q0 +## 0 3 8 21 20 11 13 +``` + +A specific plotting function makes it easy to resume most of this +information in graphic form. The plots also inform about the temporal +evolution of the bibliometric indices, which may be useful for +evaluating the scientific career of the +evaluated. + +```{r, fig.cap="A graphic bibliometric analysis"} +library(bibliometRics) +wos_file = system.file("sbegueria.txt", package = "bibliometRics") +bib <- read.wos(wos_file) +base <- read.baselines() +biblioplot(bib, quant = base$GEOSCIENCES) +``` + +The first plot reflects the productivity (quantity) of the author, as +well as its impact (citations received). It shows the cumulative number +of publications, with distinction between the publications as lead +author (black bars) and those as co-author (white bars). The plot also +showcases the number of citations for all the publications (white +circles) and for those as lead author (black circles). There is a fixed +ratio of 1:10 between the left (publications) and the right (citations) +axis, allowing for easy comparison across authors, groups, etc. This +ratio implies assuming a mean citation rate of 10 citations per article +publishes (a rate that is, of course, arbitrary). + +The second plot focuses on the impact of the publications. It shows the +annual evolution of the Hirsch’s h-index (white circles) and the Egghe’s +g-index (black circles), with a fixed ratio of 1:2 between them. +Evolution of the h-index is compared with an 1:1 evolution (dashed +line), since it is usually assumed that the h-index grows, as an +average, at a rate of 1 per year. + +The third plot attempts at evaluating the excelence of the publications. +It shows the number of publications classified by quantiles, according +to the ISI-WoK Scientific Indicators per discipline. For each quantile, +the total number of publications is shown (white bars), as well as the +publications as lead author (black bars). + +A formatted list of all the publications is also +produced. + +``` r +format_pub(cbind(bib$pubs, rank(bib,q=base$GEOSCIENCES))[1,], au=bib$au) +``` + +``` r +## [1] "\\item Quijano, Laura;\\textbf{ Begueria, Santiago}; Gaspar, Leticia; Navas, Ana. Estimating Erosion Rates using Cs-137 Measurements and Watem/Sedem in a Mediterranean Cultivated Field. \\textit{CATENA} 138: 38--51. 2016. (cit: 0; $7$)\n" +``` + +## Automated bibliometric reports + +The package also contains a template `bibliometRics.Rtex` file, useful +for creating automated reports. You’ll need to load the package `knitr` +in order to produce the report. + +``` r +require(knitr) +``` + +``` r +infile <- 'sbegueria.txt' +outfile <- 'sbegueria.Rtex' + +# Create custom .Rtex file from the template and knit it +x <- readLines('bibliometRics.Rtex') +x <- gsub('FILENAME',infile,x) +write(x,outfile) +knit(outfile) + +# Compile the resulting .tex file and create a .pdf from it +system(paste('/Library/TeX/texbin/pdflatex ', + gsub('.txt','',infile),'.tex',sep='')) + +# Remove unnecesary intermediate files +kk <- list.files('.',paste(gsub('.txt','', infile))) +file.remove(kk[-c(grep('.pdf',kk),grep('.txt',kk))]) +``` + +An example report generated by the above code chunk can be found in the +file [sbegueria.pdf]('./sbegueria.pdf'). + diff --git a/README.md b/README.md index ef50a27..b088978 100644 --- a/README.md +++ b/README.md @@ -1,48 +1,74 @@ + +[![Travis build +status](https://travis-ci.com/sbegueria/bibliometRics.svg?branch=master)](https://travis-ci.com/sbegueria/bibliometRics) +[![AppVeyor Build +Status](https://ci.appveyor.com/api/projects/status/github/sbegueria/bibliometRics?branch=master&svg=true)](https://ci.appveyor.com/project/sbegueria/bibliometRics) +[![Coverage +status](https://codecov.io/gh/sbegueria/bibliometRics/branch/master/graph/badge.svg)](https://codecov.io/gh/sbegueria/bibliometRics) + + + + # bibliometRics [![DOI](https://zenodo.org/badge/57246514.svg)](https://zenodo.org/badge/latestdoi/57246514) + Santiago Beguería 26 April 2016 - -`bibliometRics` is an R package for bibliometric analysis of scientific production. -It can be used for analysing the production of a single author, a working team, department, institute, etcetera. -This document describes the main functionalities in the package, and how to do a bibliometric analysis with `bibliometRics`, including producing automatic pdf reports via `knitr`. +`bibliometRics` is an R package for bibliometric analysis of scientific +production. It can be used for analysing the production of a single +author, a working team, department, institute, etcetera. + +This document describes the main functionalities in the package, and how +to do a bibliometric analysis with `bibliometRics`, including producing +automatic pdf reports via `knitr`. -You can cite this package on your work as: **Beguería S. (2015) bibliometRics: an R package for for bibliometric analysis of scientific production, doi:10.5281/zenodo.834260**. +You can cite this package on your work as: **Beguería S. (2015) +bibliometRics: an R package for for bibliometric analysis of scientific +production, **. ## Installation -First of all, make sure you installed the package by sourcing it (note that this is a working project, so no 'oficial' package has been created yet). +You can install this version of GitHub (note that this is a working +project): -```r -source('bibliometRics.R') +``` r +devtools::install_github("sbegueria/bibliometRics") ``` - ## Getting some bibliometric data -So far the unique source of blibiometric information accepted by `bibliometRics` is the Web of Science (WoS) by Thomson Reuters, but other sources such as Scopus or Google Scholar can be added in the future. -Publications can be selected for a given author (easiest if you know its author ID) or a group (such a research group or a department, for instance). -The WoS allows to generate a citation report, stating the number of citations received by each item, every year after its publication. -So once you are good with the selection of publications you want to analyze, you can click on the 'create citation report' button and then select the 'save to text file' option. -This will generate a text file and download it to your computer. -You may want to edit the AUTHOR field on the first line of this text file, although this is not strictly necessary for doing the analysis. - -An example citation report file from the WoS is the file [sbegueria.txt](sbegueria.txt), which contains data of papers I have authored, as of January 2017. - -The core function for reading WoS citation report data is, not surprisingly, `read.wos`. -Its only argument is the name of the data file you want to read: - - -```r +So far the unique source of blibiometric information accepted by +`bibliometRics` is the Web of Science (WoS) by Thomson Reuters, but +other sources such as Scopus or Google Scholar can be added in the +future. Publications can be selected for a given author (easiest if you +know its author ID) or a group (such a research group or a department, +for instance). The WoS allows to generate a citation report, stating the +number of citations received by each item, every year after its +publication. So once you are good with the selection of publications you +want to analyze, you can click on the ‘create citation report’ button +and then select the ‘save to text file’ option. This will generate a +text file and download it to your computer. You may want to edit the +AUTHOR field on the first line of this text file, although this is not +strictly necessary for doing the analysis. + +An example citation report file from the WoS is the file +[sbegueria.txt](sbegueria.txt), which contains data of papers I have +authored, as of January 2017. + +The core function for reading WoS citation report data is, not +surprisingly, `read.wos`. Its only argument is the name of the data file +you want to read: + +``` r bib <- read.wos('sbegueria.txt') str(bib) ``` -```r +``` r ## List of 3 ## $ author : chr "BEGUERIA, SANTIAGO" ## $ reference: chr "sbegueria" -## $ pubs :'data.frame': 88 obs. of 39 variables: +## $ pubs :'data.frame': 88 obs. of 39 variables: ## ..$ Title : chr [1:88] "Estimating erosion rates using Cs-137 measurements and WATEM/SEDEM in a Mediterranean cultivated field" "Recent changes and drivers of the atmospheric evaporative demand in the Canary Islands" "Mid and late Holocene forest fires and deforestation in the subalpine belt of the Iberian range, northern Spain" "Use of disdrometer data to evaluate the relationship of rainfall kinetic energy and intensity (KE-I)" ... ## ..$ Authors : chr [1:88] "Quijano, Laura; Begueria, Santiago; Gaspar, Leticia; Navas, Ana" "Vicente-Serrano, Sergio M.; Azorin-Molina, Cesar; Sanchez-Lorenzo, Arturo; El Kenawy, Ahmed; Martin-Hernandez, Natalia; Pena-Ga"| __truncated__ "Garcia-Ruiz, Jose M.; Sanjuan, Yasmina; Gil-Romera, Graciela; Gonzalez-Samperiz, Penelope; Begueria, Santiago; Arnaez, Jose; Co"| __truncated__ "Angulo-Martinez, M.; Begueria, S.; Kysely, J." ... ## ..$ Corporate Authors: logi [1:88] NA NA NA NA NA NA ... @@ -84,44 +110,53 @@ str(bib) ## ..$ 2017 : int [1:88] 0 0 0 0 0 0 0 0 0 0 ... ``` -The result is a list with the following three elements: -* `author`, a character object with the name of the author being analysed; -* `reference`, a character object; and -* `pubs`, a data frame with the publications in rows, and the data referring to each publications in columns, including the number of citations received, year by year. - +The result is a list with the following three elements: \* `author`, a +character object with the name of the author being analysed; \* +`reference`, a character object; and \* `pubs`, a data frame with the +publications in rows, and the data referring to each publications in +columns, including the number of citations received, year by year. ## Analyzing bibliometric data -The main function for analyizing these data is `bibliometric`. -It takes an object with the bibliometric data resulting from a call to `read.wos` and returns a data.frame with a number of bibliometric indices. +The main function for analyizing these data is `bibliometric`. It takes +an object with the bibliometric data resulting from a call to `read.wos` +and returns a data.frame with a number of bibliometric indices. -In order to compute some metrics which are based on the number of citations received by each publication, data on the percentile baselines for each scientific discipline is requireed. -This data can be found on another Thomson Reuters product, the 'Essential Science Indicators' database. -You need to navigate to the 'Field Baselines' tab, and then select 'Percentiles' to get the field percentile baselines (FPB). -You can then download the FPB table in csv format. +In order to compute some metrics which are based on the number of +citations received by each publication, data on the percentile baselines +for each scientific discipline is requireed. This data can be found on +another Thomson Reuters product, the ‘Essential Science Indicators’ +database. You need to navigate to the ‘Field Baselines’ tab, and then +select ‘Percentiles’ to get the field percentile baselines (FPB). You +can then download the FPB table in csv format. -An example FPB table as of January 2017 can be found in file [BaselinePercentiles.csv](BaselinePercentiles.csv). -This table can be read with the function 'read.baselines': +An example FPB table as of January 2017 can be found in file +[BaselinePercentiles.csv](BaselinePercentiles.csv). This table can be +read with the function ‘read.baselines’: -```r +``` r base <- read.baselines('BaselinePercentiles.csv') ``` -The resulting object is a list with as many items as disciplines. -For each discipline, a data.frame is stored containing the threshold number of citations corresponding to each percentile, depending on the publication year. -For instance, this is are the baseline thresholds for the discipline 'Geosciences': +The resulting object is a list with as many items as disciplines. For +each discipline, a data.frame is stored containing the threshold number +of citations corresponding to each percentile, depending on the +publication year. For instance, this is are the baseline thresholds for +the discipline ‘Geosciences’: -```r +``` r base$GEOSCIENCES ``` -We can now use the function `bibliometric`, especifying the, the field baselines, and the discipline (the table for 'all fields' will be used as a default if no discipline is specified). +We can now use the function `bibliometric`, especifying the, the field +baselines, and the discipline (the table for ‘all fields’ will be used +as a default if no discipline is specified). -```r +``` r bibliometric(bib, base, 'GEOSCIENCES') ``` -```r +``` r ## name ini years pubs lead pubs_year hin hin_year ## 1 BEGUERIA, SANTIAGO 2000 16 88 17 5.5 33 2.06 ## gin gin_year cit_tot cit_year cit_art ifact2 ifact5 i10 i25 i50 @@ -130,78 +165,79 @@ bibliometric(bib, base, 'GEOSCIENCES') ## 1 616 32 7 11 4145 187 ``` -These are the following: - - Label | Meaning ----------------| ---------------------------------------------------- - name | Name of the author, group, department, etc. - ini | Initial year of the publication record - span | Time span (years) of the publication record - pubs | Total number of publications - lead | Total number of publications, as the lead (first) author - pubs_year | Mean number of publications per year - hin | Hirsch's h-index - hin_year | h-index per year - gin | Egghe's g-index - gin_year | g-index per year - cit_tot | Total number of citations - cit_year | Mean number of citations per year - cit_art | Mean number of citations per article - ifact2 | Impact factor, computed over the last two years - ifact5 | Impact factor, computed over the last five years - i10 | Number of publications with 10 or more citations - i25 | Number of publications with 25 or more citations - i50 | Number of publications with 50 or more citations - cit_max | Number of citations of the most citated publications - pubs09 | Number of publications over the 90th percentile in its discipline - pubs09_lead | Number of publications over the 90th percentile in its discipline, as lead author - pubs099 | Number of publications over the 99th percentile in its discipline - iscore | i-score - iscore_lead | i-score, as lead author - -There are functions for computing some of the indices, such as the Hirsch and the Egghe indices. -These can be computed for the whole period analyized, or up to a given year. - - -```r +These are the +following: + +| Label | Meaning | +| ------------ | --------------------------------------------------------------------------------- | +| name | Name of the author, group, department, etc. | +| ini | Initial year of the publication record | +| span | Time span (years) of the publication record | +| pubs | Total number of publications | +| lead | Total number of publications, as the lead (first) author | +| pubs\_year | Mean number of publications per year | +| hin | Hirsch’s h-index | +| hin\_year | h-index per year | +| gin | Egghe’s g-index | +| gin\_year | g-index per year | +| cit\_tot | Total number of citations | +| cit\_year | Mean number of citations per year | +| cit\_art | Mean number of citations per article | +| ifact2 | Impact factor, computed over the last two years | +| ifact5 | Impact factor, computed over the last five years | +| i10 | Number of publications with 10 or more citations | +| i25 | Number of publications with 25 or more citations | +| i50 | Number of publications with 50 or more citations | +| cit\_max | Number of citations of the most citated publications | +| pubs09 | Number of publications over the 90th percentile in its discipline | +| pubs09\_lead | Number of publications over the 90th percentile in its discipline, as lead author | +| pubs099 | Number of publications over the 99th percentile in its discipline | +| iscore | i-score | +| iscore\_lead | i-score, as lead author | + +There are functions for computing some of the indices, such as the +Hirsch and the Egghe indices. These can be computed for the whole period +analyized, or up to a given year. + +``` r hirsch(bib) ``` -```r +``` r ## [1] 33 ``` -```r +``` r egghe(bib) ``` -```r +``` r ## [1] 57 ``` -```r +``` r hirsch(bib, 2010) ``` -```r +``` r ## [1] 13 ``` -```r +``` r egghe(bib, 2010) ``` -```r +``` r ## [1] 45 ``` There is also a function for ranking the publications in quantiles: -```r +``` r rank(bib, q=base$GEOSCIENCES) ``` -```r +``` r ## [1] >q0 >q0 >q0 >q0 >q0.9 >q0.9 >q0.99 >q0 ## [9] >q0.8 >q0.8 >q0.9 >q0.9 >q0.99 >q0.99 >q0.99 >q0.999 ## [17] >q0 >q0.99 >q0.99 >q0.5 >q0.9 >q0.9 >q0.999 >q0 @@ -216,56 +252,77 @@ rank(bib, q=base$GEOSCIENCES) ## Levels: >q0.9999 >q0.999 >q0.99 >q0.9 >q0.8 >q0.5 >q0 ``` -```r +``` r table(rank(bib, q=base$GEOSCIENCES)) ``` -```r + +``` r ## >q0.9999 >q0.999 >q0.99 >q0.9 >q0.8 >q0.5 >q0 ## 0 3 8 21 20 11 13 ``` - -A specific plotting function makes it easy to resume most of this information in graphic form. -The plots also inform about the temporal evolution of the bibliometric indices, which may be useful for evaluating the scientific career of the evaluated. - - -```r -biblioplot(bib, q=base$GEOSCIENCES) +A specific plotting function makes it easy to resume most of this +information in graphic form. The plots also inform about the temporal +evolution of the bibliometric indices, which may be useful for +evaluating the scientific career of the evaluated. + +``` r +library(bibliometRics) +wos_file = system.file("sbegueria.txt", package = "bibliometRics") +bib <- read.wos(wos_file) +base <- read.baselines() +biblioplot(bib, quant = base$GEOSCIENCES) ``` -
-A graphic bibliometric analysis -

A graphic bibliometric analysis

-
- -The first plot reflects the productivity (quantity) of the author, as well as its impact (citations received). It shows the cumulative number of publications, with distinction between the publications as lead author (black bars) and those as co-author (white bars). The plot also showcases the number of citations for all the publications (white circles) and for those as lead author (black circles). There is a fixed ratio of 1:10 between the left (publications) and the right (citations) axis, allowing for easy comparison across authors, groups, etc. This ratio implies assuming a mean citation rate of 10 citations per article publishes (a rate that is, of course, arbitrary). - -The second plot focuses on the impact of the publications. It shows the annual evolution of the Hirsch's h-index (white circles) and the Egghe's g-index (black circles), with a fixed ratio of 1:2 between them. Evolution of the h-index is compared with an 1:1 evolution (dashed line), since it is usually assumed that the h-index grows, as an average, at a rate of 1 per year. - -The third plot attempts at evaluating the excelence of the publications. It shows the number of publications classified by quantiles, according to the ISI-WoK Scientific Indicators per discipline. For each quantile, the total number of publications is shown (white bars), as well as the publications as lead author (black bars). - -A formatted list of all the publications is also produced. - -```r +![A graphic bibliometric +analysis](man/figures/README-unnamed-chunk-1-1.png) + +The first plot reflects the productivity (quantity) of the author, as +well as its impact (citations received). It shows the cumulative number +of publications, with distinction between the publications as lead +author (black bars) and those as co-author (white bars). The plot also +showcases the number of citations for all the publications (white +circles) and for those as lead author (black circles). There is a fixed +ratio of 1:10 between the left (publications) and the right (citations) +axis, allowing for easy comparison across authors, groups, etc. This +ratio implies assuming a mean citation rate of 10 citations per article +publishes (a rate that is, of course, arbitrary). + +The second plot focuses on the impact of the publications. It shows the +annual evolution of the Hirsch’s h-index (white circles) and the Egghe’s +g-index (black circles), with a fixed ratio of 1:2 between them. +Evolution of the h-index is compared with an 1:1 evolution (dashed +line), since it is usually assumed that the h-index grows, as an +average, at a rate of 1 per year. + +The third plot attempts at evaluating the excelence of the publications. +It shows the number of publications classified by quantiles, according +to the ISI-WoK Scientific Indicators per discipline. For each quantile, +the total number of publications is shown (white bars), as well as the +publications as lead author (black bars). + +A formatted list of all the publications is also +produced. + +``` r format_pub(cbind(bib$pubs, rank(bib,q=base$GEOSCIENCES))[1,], au=bib$au) ``` -```r +``` r ## [1] "\\item Quijano, Laura;\\textbf{ Begueria, Santiago}; Gaspar, Leticia; Navas, Ana. Estimating Erosion Rates using Cs-137 Measurements and Watem/Sedem in a Mediterranean Cultivated Field. \\textit{CATENA} 138: 38--51. 2016. (cit: 0; $7$)\n" ``` - ## Automated bibliometric reports -The package also contains a template `bibliometRics.Rtex` file, useful for creating automated reports. -You'll need to load the package `knitr` in order to produce the report. +The package also contains a template `bibliometRics.Rtex` file, useful +for creating automated reports. You’ll need to load the package `knitr` +in order to produce the report. -```r +``` r require(knitr) ``` - -```r +``` r infile <- 'sbegueria.txt' outfile <- 'sbegueria.Rtex' @@ -277,11 +334,12 @@ knit(outfile) # Compile the resulting .tex file and create a .pdf from it system(paste('/Library/TeX/texbin/pdflatex ', - gsub('.txt','',infile),'.tex',sep='')) + gsub('.txt','',infile),'.tex',sep='')) # Remove unnecesary intermediate files kk <- list.files('.',paste(gsub('.txt','', infile))) file.remove(kk[-c(grep('.pdf',kk),grep('.txt',kk))]) ``` -An example report generated by the above code chunk can be found in the file [sbegueria.pdf]('./sbegueria.pdf'). +An example report generated by the above code chunk can be found in the +file [sbegueria.pdf]('./sbegueria.pdf'). diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..87e9fec --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,38 @@ +init: + ps: | + $ErrorActionPreference = "Stop" + Invoke-WebRequest http://raw.github.com/krlmlr/r-appveyor/master/scripts/appveyor-tool.ps1 -OutFile "..\appveyor-tool.ps1" + Import-Module '..\appveyor-tool.ps1' +install: + ps: Bootstrap +cache: C:\RLibrary +build_script: travis-tool.sh install_deps +test_script: travis-tool.sh run_tests +on_failure: + - 7z a failure.zip *.Rcheck\* + - appveyor PushArtifact failure.zip +artifacts: + - path: '*.Rcheck\**\*.log' + name: Logs + - path: '*.Rcheck\**\*.out' + name: Logs + - path: '*.Rcheck\**\*.fail' + name: Logs + - path: '*.Rcheck\**\*.Rout' + name: Logs + - path: \*_*.zip + name: Bits +environment: + global: + WARNINGS_ARE_ERRORS: 1.0 + USE_RTOOLS: yes + R_CHECK_INSTALL_ARGS: --install-args=--build --no-multiarch +deploy: + provider: GitHub + description: Windows Binary + auth_token: + secure: tc2Va9OWLH9H/uKPUKCUmv+q+wQpzRVJd6t8ckXjqzGnOo9eWyiQCmuuUjcuM3b8 + draft: no + prerelease: no + 'on': + appveyor_repo_tag: true diff --git a/bibliometRics.R b/bibliometRics.R deleted file mode 100644 index 94c36d3..0000000 --- a/bibliometRics.R +++ /dev/null @@ -1,411 +0,0 @@ -# Functions to read and process Web of Science citation report data. - -read.wos <- function(infile) { - - # author - au <- read.table(infile, sep=',', nrows=1, stringsAsFactors=FALSE) - #au <- paste(gsub('AUTHOR: \\(','',au[1]),gsub('\\)','',au[2]),sep=', ') - au <- paste(gsub('(AUTHOR)( IDENTIFIERS)*(: \\()','',au[1]), gsub('\\)','',au[2]),sep=', ') - au <- toupper(au) - - # reference - re <- gsub('.txt','',rev(strsplit(infile,'/')[[1]])[1]) - - # read publications - nskip <- ifelse (read.table(infile,sep=',',nrows=1,skip=1)=='null', 5, 4) - dat <- read.table(infile, sep=',', stringsAsFactors=FALSE, skip=nskip) - colnames(dat) <- read.table(infile,sep=',',stringsAsFactors=FALSE,skip=nskip-1,nrows=1) - o <- rev(order(dat[,'Publication Year'])) - dat <- dat[o,] - start <- min(dat[,'Publication Year']) - w <- which(colnames(dat)==start) - dat <- dat[,c(1:21,w:ncol(dat))] - - return(list(author=au,reference=re,pubs=dat)) -} -#bib <- read.isiwok('isiwok_MAM.txt') - - -# read.scopus <- function(infile) { - - # # author - # au <- read.table(infile,sep=',',nrows=1,stringsAsFactors=FALSE)[,2] - # au <- substr(au,9,nchar(au)) - - # # read publications - # dat <- read.table(infile,sep=',',stringsAsFactors=FALSE,skip=7)[,c(1:7,9,12)] - # colnames(dat) <- c('year','title','authors','issn','journal','volume','issue','cit','cittotal') - - # return() -# } -# bib <- read.scopus('scopus_SBP_win.csv') - -# Read field percentile baselines (FPB) from the Essential Science Indicators database. -read.baselines <- function(infile) { - fpb <- read.table(infile, sep=',', skip=1, stringsAsFactors=FALSE, head=TRUE) - fields <- fpb$RESEARCH.FIELDS[-grep('%|©', fpb$RESEARCH.FIELDS)] - baselines <- list(NULL) - for (i in 1:length(fields)) { - w <- which(fpb$RESEARCH.FIELDS==fields[i]) - baselines[[i]] <- fpb[w+1:6,] - colnames(baselines[[i]])[1] <- 'percentiles' - names(baselines)[i] <- fields[i] - } - return(baselines) -} - -# Hirsch's h-index -hirsch <- function(x,y=NULL) { - x <- x$pubs - if (is.null(y)) { - #y <- max(x[,'Publication Year']) - y <- rev(colnames(x))[1] - } - w <- which(x[,'Publication Year']<=y) - ww <- which(colnames(x)<=y) - if (length(ww)>1) { - cit <- rowSums(x[w,ww]) - } else { - cit <- x[w,ww] - } - #cit <- x[,'Total Citations'] - hin <- cbind(cit[order(cit,decreasing=TRUE)],1:length(cit)) - w <- (hin[,1]-hin[,2])>0 - if (sum(w)==0) return(0) - return(max(hin[w,2])) -} -#hirsch(bib) -#hirsch(bib, 2010) - - -# Egghe's g-index -egghe <- function(x,y=NULL) { - x <- x$pubs - if (is.null(y)) { - y <- max(x[,'Publication Year']) - } - w <- x[,'Publication Year']<=y - cit <- x[w,'Total Citations'] - gin <- cbind( - 1:length(cit), - cumsum(cit[order(cit,decreasing=TRUE)]), - (1:length(cit))^2) - w <- (gin[,2]-gin[,3])>0 - return(max(gin[w,1])) -} -#egghe(bib) - -# citation ranking (quantiles) -rank <- function(x, w=NULL, q=NULL) { - x <- x$pubs - if (!is.null(w)) { - x <- x[w,] - } - r <- data.frame(a=x[,'Publication Year'],b=x[,'Total Citations'],c='') - r$c <- factor(r$c,levels=c('>q0.9999','>q0.999','>q0.99','>q0.9','>q0.8','>q0.5','>q0')) - for (i in 1:nrow(r)) { - w <- grep(r[i,1],names(q)) - if (length(w)==0) next() - ww <- which(r[i,2]-q[,w]>=0)[1] - if (is.na(ww)) { - r[i,3] <- levels(r$c)[7] - } else { - r[i,3] <- levels(r$c)[ww] - } - } - return(r[,3]) -} -#rank(bib, c(9,10), quant) -#rank(bib, quant) - -# impact factor -ifactor <- function(x, y=NULL, n=2) { - year <- x[,'Publication Year'] - if (is.null(y)) { - y <- max(year)-1 - } - w <- which(year>={y-n} & year=n)) - } - i10 <- icit(dat) - i25 <- icit(dat,25) - i50 <- icit(dat,50) - - # h-index - hin <- hirsch(bib) - - # g-index - gin <- egghe(bib) - - # pubs >0.9, >0.99 - r <- rank(bib, q=quant) - p09 <- sum(as.numeric(r)<=4,na.rm=TRUE) - p099 <- sum(as.numeric(r)<=3,na.rm=TRUE) - - # pubs >0.9, as lead author - r_lead <- rank(bib, pubs_lead, quant) - p09_lead <- sum(as.numeric(r_lead)<=4,na.rm=TRUE) - - # i-score - scores <- c(1/(1-0.9999),1/(1-0.999),1/(1-0.99),1/(1-0.9),1/(1-0.8),1/(1-0.5),1/1) - iscore <- sum(scores[as.numeric(r)],na.rm=TRUE) - - # i-score, as lead author - isc_lead <- sum(scores[as.numeric(r_lead)],na.rm=TRUE) - - # output - out <- as.data.frame(t(c(name=au, - ini,span,pubs,length(pubs_lead),round(pubs/span,2), - hin,round(hin/span,2),gin,round(gin/span,2), - cit_tot,round(cit_tot/span,2),cit_art,ifact2,ifact5, - i10,i25,i50,cit_max,p09,p09_lead,p099,round(iscore,2),round(isc_lead,2)))) - colnames(out) <- c('name','ini','years','pubs','lead','pubs_year','hin','hin_year', - 'gin','gin_year','cit_tot','cit_year','cit_art','ifact2','ifact5','i10','i25', - 'i50','cit_max','pubs09','pubs09_lead','pubs099','iscore','iscore_lead') - return(out) -} -#bibliometric(bib, baseline) - -biblioplot <- function(bib, quant) { - - par(mfrow=c(1,3)) - - au <- bib$author - dat <- bib$pubs - - # Publication range - pubrange <- range(dat[,'Publication Year']) - - # Leading authors - leads <- as.character(lapply(dat[,'Authors'],function(x) {strsplit(x,';')[[1]][1]})) - w_lead <- grep(strsplit(gsub('Ñ','N',au),',')[[1]][1], leads, ignore.case=TRUE) - - # Publications and citations - # pubs per year - years <- dat[,'Publication Year'] - years <- factor(years,levels=as.character(min(years):max(years))) - years_nolead <- years[-w_lead] - years_lead <- years[w_lead] - pubs <- rbind(table(years_lead),table(years_nolead)) - rownames(pubs) <- c('pubs_lead','pubs_nolead') - # cumulative pubs - pubs_cum <- t(apply(pubs,1,cumsum)) - # citations per year - cits_lead <- t(as.matrix(colSums(bib$pubs[w_lead,22:ncol(bib$pubs)]))) - cits_nolead <- t(as.matrix(colSums(bib$pubs[-w_lead,22:ncol(bib$pubs)]))) - cits <- rbind(cits_lead,cits_nolead) - rownames(cits) <- c('cits_lead','cits_nolead') - w <- colnames(cits)>=pubrange[1] & colnames(cits)<=pubrange[2] - cits <- cits[,w] - # cumulative citations - cits_cum <- t(apply(cits,1,cumsum)) - # plot - par(mar=c(5, 4, 4, 4)+0.1) - ylabs <- pretty(c(0,max(max(colSums(pubs_cum)),ceiling(max(colSums(cits_cum))/10)))) - ylims <- c(min(ylabs),max(ylabs)) - pubbar <- barplot(pubs_cum,ylim=ylims,ylab='',yaxt='n') - abline(h=ylabs,col='lightgray',lty='dotted') - par(new=TRUE) - pubbar <- barplot(pubs_cum,ylim=ylims,ylab='',yaxt='n') - lines(x=pubbar,y=cits_cum['cits_lead',]/10) - points(x=pubbar,y=cits_cum['cits_lead',]/10,pch=19) - lines(x=pubbar,y=colSums(cits_cum)/10) - points(x=pubbar,y=colSums(cits_cum)/10,pch=19,col='lightgray') - points(x=pubbar,y=colSums(cits_cum)/10,pch=21) - axis(2) - axis(4,at=pretty(ylims),labels=pretty(ylims)*10) - mtext('Pubs',2,line=2.5,cex=0.75) - mtext('Citations',4,line=2.5,cex=0.75) - - # h- and g-index - years <- c(min(dat[,'Publication Year']):max(dat[,'Publication Year'])) - hh <- NULL - gg <- NULL - for (y in years) { - hh <- c(hh,hirsch(bib,y)) - gg <- c(gg,egghe(bib,y)) - } - # plot - ylabs <- pretty(c(0,max(max(hh),ceiling(max(gg)/2)))) - ylims <- c(min(ylabs),max(ylabs)) - plot(x=years,y=hh,type='n',ylab='',xlab='',ylim=ylims) - abline(h=pretty(hh),col='lightgray',lty='dotted') - lines(years,0:{length(years)-1},lty='dashed') - lines(x=years,y=hh) - points(x=years,y=hh,pch=19) - mtext('h-index',2,line=2.5,cex=0.75) - par(new=TRUE) - lines(x=years,y=gg/2) - points(x=years,y=gg/2,pch=19,col='lightgray') - points(x=years,y=gg/2,pch=21) - axis(4,at=pretty(ylims),labels=pretty(ylims)*2) - mtext('g-index',4,line=2.5,cex=0.75) - - # Excelence - exc <- rbind(rev(table(rank(bib, w_lead, q=quant))),rev(table(rank(bib, -w_lead, q=quant))))[,-7] - rownames(exc) <- c('pubs_lead','pubs_nolead') - # plot - barplot(exc) - abline(h=pretty(colSums(exc)),col='lightgray',lty='dotted') - par(new=TRUE) - barplot(exc) - mtext('Counts',2,line=2.5,cex=0.75) -} -#biblioplot(bib) - -biblioplot2 <- function(bib) { - - par(mfrow=c(1,2)) - - au <- bib$author - dat <- bib$pubs - - # Publication range - pubrange <- range(dat[,'Publication Year']) - - # Leading authors - leads <- as.character(lapply(dat[,'Authors'],function(x) {strsplit(x,';')[[1]][1]})) - - # Publications and citations - # pubs per year - years <- dat[,'Publication Year'] - years <- factor(years,levels=as.character(min(years):max(years))) - pubs <- table(years) - # cumulative pubs - pubs_cum <- cumsum(pubs) - # citations per year - cits <- t(as.matrix(colSums(bib$pubs[,22:ncol(bib$pubs)]))) - rownames(cits) <- c('cits') - w <- colnames(cits)>=pubrange[1] & colnames(cits)<=pubrange[2] - cits <- cits[,w] - # cumulative citations - cits_cum <- cumsum(cits) - # plot - par(mar=c(5, 4, 4, 4)+0.1) - ylabs <- pretty(c(0,max(max(pubs_cum),ceiling(max(cits_cum)/10)))) - ylims <- c(min(ylabs),max(ylabs)) - pubbar <- barplot(pubs_cum,ylim=ylims,ylab='',yaxt='n') - abline(h=ylabs,col='lightgray',lty='dotted') - par(new=TRUE) - pubbar <- barplot(pubs_cum,ylim=ylims,ylab='',yaxt='n') - lines(x=pubbar,y=cits_cum/10) - points(x=pubbar,y=cits_cum/10,pch=19) - axis(2) - axis(4,at=pretty(ylims),labels=pretty(ylims)*10) - mtext('Pubs',2,line=2.5,cex=0.75) - mtext('Citations',4,line=2.5,cex=0.75) - title('Publications and citations') - - # h-index - years <- c(min(dat[,'Publication Year']):max(dat[,'Publication Year'])) - hh <- NULL - for (y in years) { - hh <- c(hh,hirsch(bib,y)) - gg <- c(gg,egghe(bib,y)) - } - # plot - ylabs <- pretty(c(0,max(max(hh)))) - ylims <- c(min(ylabs),max(ylabs)) - plot(x=years,y=hh,type='n',ylab='',xlab='',ylim=ylims) - abline(h=pretty(hh),col='lightgray',lty='dotted') - lines(years,0:{length(years)-1},lty='dashed') - lines(x=years,y=hh) - points(x=years,y=hh,pch=19) - mtext('h-index',2,line=2.5,cex=0.75) - title('h-index') -} - - -format_pub <- function(x,au) { - # format authors - if (substr(x['Authors'],nchar(x['Authors']),nchar(x['Authors']))!='.') { - x['Authors'] <- paste(x['Authors'],'.',sep='') - } - auths <- strsplit(as.character(x['Authors']),';')[[1]] - w <- grep(strsplit(gsub('Ñ','N',au),',')[[1]][1],auths,ignore.case=TRUE) - auths[w]<- paste('\\textbf{',auths[w],'}',sep='') - auths <- paste0(auths,sep=';',collapse='') - auths <- substr(auths,1,nchar(auths)-1) - # format citations rank - w <- grep('rank',names(x)) -# if (is.na(x[,w]) | x[,w]=='') { - if (is.na(x[w])) { - rank <- '' - } else { -# rank <- paste('; $',x[,w],'$',sep='') - rank <- paste('; $',x[w],'$',sep='') - } - # format title - require(tools) - title <- gsub('&','\\\\&',toTitleCase(tolower(as.character(x['Title'])))) - # format source - source <- gsub('&','\\\\&',x['Source Title']) - # format volume and pages - if (is.na(x['Volume'])) { - vol <- '' - } else { - vol <- paste(' ',x['Volume'],sep='') - } - if (is.na(x['Issue']) | x['Issue']=='') { - issue <- '' - } else { - issue <- paste('(',x['Issue'],')',sep='') - } - if (is.na(x['Beginning Page']) | x['Beginning Page']=='' | - is.na(x['Ending Page']) | x['Ending Page']=='') { - if (is.na(x['Article Number']) | x['Article Number']=='') { - pages <- '' - } else { - pages <- paste(': ', x['Article Number'],sep='') - } - } else { - pages <- paste(': ',x['Beginning Page'],'--',x['Ending Page'],sep='') - } - # put everything together - paste('\\item ',auths,' ',title,'. ', - '\\textit{',source,'}',vol,issue,pages,'. ', - x['Publication Year'],'. ', - '(cit: ',x['Total Citations'],rank,')\n', sep='') -} - diff --git a/bibliometRics.Rproj b/bibliometRics.Rproj new file mode 100644 index 0000000..64565bc --- /dev/null +++ b/bibliometRics.Rproj @@ -0,0 +1,22 @@ +Version: 1.0 + +RestoreWorkspace: No +SaveWorkspace: No +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 +Encoding: UTF-8 + +RnwWeave: knitr +LaTeX: pdfLaTeX + +AutoAppendNewline: Yes +StripTrailingWhitespace: Yes + +BuildType: Package +PackageUseDevtools: Yes +PackageInstallArgs: --no-multiarch --with-keep.source +PackageCheckArgs: --as-cran +PackageRoxygenize: rd,collate,namespace diff --git a/biblioplot_example.pdf b/biblioplot_example.pdf deleted file mode 100644 index 2764e40..0000000 Binary files a/biblioplot_example.pdf and /dev/null differ diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..8f36b6c --- /dev/null +++ b/codecov.yml @@ -0,0 +1,12 @@ +comment: false + +coverage: + status: + project: + default: + target: auto + threshold: 1% + patch: + default: + target: auto + threshold: 1% diff --git a/BaselinePercentiles.csv b/inst/BaselinePercentiles.csv similarity index 100% rename from BaselinePercentiles.csv rename to inst/BaselinePercentiles.csv diff --git a/bibliometRics.Rtex b/inst/bibliometRics.Rtex similarity index 100% rename from bibliometRics.Rtex rename to inst/bibliometRics.Rtex diff --git a/sbegueria.txt b/inst/sbegueria.txt similarity index 100% rename from sbegueria.txt rename to inst/sbegueria.txt diff --git a/man/bibliometric.Rd b/man/bibliometric.Rd new file mode 100644 index 0000000..9dc1875 --- /dev/null +++ b/man/bibliometric.Rd @@ -0,0 +1,35 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/bibliometRics.R +\name{bibliometric} +\alias{bibliometric} +\title{Calculate Bibliometrics} +\usage{ +bibliometric(bib, base = read.baselines(), discipline = NULL) +} +\arguments{ +\item{bib}{A list with an element called \code{pubs}, which is a +\code{data.frame} with columns \code{'Publication Year'} and +\code{'Total Citations'}. Usually +from \code{\link{read.wos}}} + +\item{base}{Baseline percentages} + +\item{discipline}{Name of Discipline, must be in column names of +\code{base}} +} +\value{ +A \code{data.frame} of metric +} +\description{ +Calculate Bibliometrics +} +\examples{ +wos_file = system.file("sbegueria.txt", package = "bibliometRics") +bib <- read.wos(wos_file) +bib$author = gsub('[ñÑ]', 'N', bib$author) +bib$pubs$Authors = gsub('[ñÑ]', 'N', bib$pubs$Authors) + +base = read.baselines() +discipline = 'GEOSCIENCES' +bibliometric(bib, base, 'GEOSCIENCES') +} diff --git a/man/biblioplot.Rd b/man/biblioplot.Rd new file mode 100644 index 0000000..e824832 --- /dev/null +++ b/man/biblioplot.Rd @@ -0,0 +1,29 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/plot.R +\name{biblioplot} +\alias{biblioplot} +\alias{biblioplot2} +\title{Plot Bibliometrics} +\usage{ +biblioplot(bib, quant) + +biblioplot2(bib) +} +\arguments{ +\item{bib}{A list with an element called \code{pubs}, which is a +\code{data.frame} with columns \code{'Publication Year'} and +\code{'Total Citations'}. Usually +from \code{\link{read.wos}}} + +\item{quant}{Quantile, passed to \code{\link{citation_rank}}} +} +\description{ +Plot Bibliometrics +} +\examples{ +wos_file = system.file("sbegueria.txt", package = "bibliometRics") +bib <- read.wos(wos_file) +base = read.baselines() +biblioplot(bib, q=base$GEOSCIENCES) +bib$author = gsub('Ñ', 'N', bib$author) +} diff --git a/man/citation_rank.Rd b/man/citation_rank.Rd new file mode 100644 index 0000000..34548fe --- /dev/null +++ b/man/citation_rank.Rd @@ -0,0 +1,34 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/citation_rank.R +\name{citation_rank} +\alias{citation_rank} +\title{Calculate citation ranking (quantiles)} +\usage{ +citation_rank(x, w = NULL, quant = NULL) +} +\arguments{ +\item{x}{A list with an element called \code{pubs}, which is a +\code{data.frame} with columns \code{'Publication Year'} and +\code{'Total Citations'}. Usually +from \code{\link{read.wos}}} + +\item{w}{column indicators of which quantiles to grab} + +\item{quant}{A \code{data.frame}? maybe} +} +\value{ +A scalar number +} +\description{ +Calculate citation ranking (quantiles) +} +\examples{ +wos_file = system.file("sbegueria.txt", package = "bibliometRics") +bib <- read.wos(wos_file) +hirsch(bib) +hirsch(bib, 2010) +egghe(bib) +egghe(bib, 2010) +base = read.baselines() +citation_rank(bib, quant=base$GEOSCIENCES) +} diff --git a/man/figures/README-unnamed-chunk-1-1.png b/man/figures/README-unnamed-chunk-1-1.png new file mode 100644 index 0000000..62f124d Binary files /dev/null and b/man/figures/README-unnamed-chunk-1-1.png differ diff --git a/man/format_pub.Rd b/man/format_pub.Rd new file mode 100644 index 0000000..512a41e --- /dev/null +++ b/man/format_pub.Rd @@ -0,0 +1,32 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/format_pub.R +\name{format_pub} +\alias{format_pub} +\title{Format Publication data} +\usage{ +format_pub(x, au) +} +\arguments{ +\item{x}{A list with an element called \code{pubs}, which is a +\code{data.frame} with columns \code{'Publication Year'} and +\code{'Total Citations'}. Usually +from \code{\link{read.wos}}} + +\item{au}{Author to grab publications} +} +\value{ +A character vector +} +\description{ +Format Publication data +} +\examples{ +wos_file = system.file("sbegueria.txt", package = "bibliometRics") +bib <- read.wos(wos_file) +base = read.baselines() +au = bib$au +au = gsub('Ñ', 'N', au) +format_pub(cbind(bib$pubs, +citation_rank(bib,quant=base$GEOSCIENCES))[1,], + au=au) +} diff --git a/man/hirsch.Rd b/man/hirsch.Rd new file mode 100644 index 0000000..47b69cf --- /dev/null +++ b/man/hirsch.Rd @@ -0,0 +1,40 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/hirsch.R +\name{hirsch} +\alias{hirsch} +\alias{egghe} +\alias{ifactor} +\title{Calculate Hirsch's h-index or Egghe's g-index} +\usage{ +hirsch(bib, year = NULL) + +egghe(bib, year = NULL) + +ifactor(bib, year = NULL, n = 2) +} +\arguments{ +\item{bib}{A list with an element called \code{pubs}, which is a +\code{data.frame} with column \code{'Publication Year'}. Usually +from \code{\link{read.wos}}} + +\item{year}{Maximum year to include for calculation} + +\item{n}{number of years} +} +\value{ +A scalar number +} +\description{ +Calculate Hirsch's h-index or Egghe's g-index +} +\examples{ +wos_file = system.file("sbegueria.txt", package = "bibliometRics") +bib <- read.wos(wos_file) +hirsch(bib) +hirsch(bib, 2010) +egghe(bib) +egghe(bib, 2010) +ifactor(bib) # 2-year impact factor +ifactor(bib,2013) # 2-year impact factor, year 2013 +ifactor(bib,n=5) # 5-year impact factor#' +} diff --git a/man/read.baselines.Rd b/man/read.baselines.Rd new file mode 100644 index 0000000..de77ad0 --- /dev/null +++ b/man/read.baselines.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/read.baselines.R +\name{read.baselines} +\alias{read.baselines} +\title{Read field percentile baselines (FPB) from the Essential Science +Indicators database.} +\usage{ +read.baselines(infile = system.file("BaselinePercentiles.csv", package = + "bibliometRics")) +} +\arguments{ +\item{infile}{Baseline percentages for each field} +} +\value{ +A \code{list} of percentages +} +\description{ +Read field percentile baselines (FPB) from the Essential Science +Indicators database. +} +\examples{ +res = read.baselines() +} diff --git a/man/read.wos.Rd b/man/read.wos.Rd new file mode 100644 index 0000000..671c170 --- /dev/null +++ b/man/read.wos.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/read.wos.R +\name{read.wos} +\alias{read.wos} +\title{Read and process Web of Science citation report data.} +\usage{ +read.wos(infile) +} +\arguments{ +\item{infile}{Input text file from Web of Science} +} +\value{ +A list of information +} +\description{ +Read and process Web of Science citation report data. +} +\examples{ +wos_file = system.file('sbegueria.txt', package = "bibliometRics") +bib <- read.wos(wos_file) +} diff --git a/sbegueria.pdf b/sbegueria.pdf deleted file mode 100644 index 635c4c5..0000000 Binary files a/sbegueria.pdf and /dev/null differ diff --git a/tests/testthat.R b/tests/testthat.R new file mode 100644 index 0000000..5708d70 --- /dev/null +++ b/tests/testthat.R @@ -0,0 +1,4 @@ +library(testthat) +library(bibliometRics) + +test_check("bibliometRics") diff --git a/tests/testthat/test-biblio.R b/tests/testthat/test-biblio.R new file mode 100644 index 0000000..c307144 --- /dev/null +++ b/tests/testthat/test-biblio.R @@ -0,0 +1,15 @@ +testthat::context("Just a simple test") + + +testthat::test_that("bibliometric works", { + + wos_file = system.file("sbegueria.txt", package = "bibliometRics") + testthat::expect_silent({ + bib <- read.wos(wos_file) + }) + base = read.baselines() + discipline = 'GEOSCIENCES' + testthat::expect_silent({ + bibliometric(bib, base, 'GEOSCIENCES') + }) +}) diff --git a/vignettes/.gitignore b/vignettes/.gitignore new file mode 100644 index 0000000..097b241 --- /dev/null +++ b/vignettes/.gitignore @@ -0,0 +1,2 @@ +*.html +*.R diff --git a/vignettes/example_report.Rmd b/vignettes/example_report.Rmd new file mode 100644 index 0000000..31d79e9 --- /dev/null +++ b/vignettes/example_report.Rmd @@ -0,0 +1,75 @@ +--- +title: "Vignette Title" +author: "Vignette Author" +date: "`r Sys.Date()`" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{Vignette Title} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + +```{r setup, include = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>" +) +``` + + + + +```{r bibdata, include=FALSE} +library(bibliometRics) +wos_file = system.file("sbegueria.txt", package = "bibliometRics") +bib <- read.wos(wos_file) +quant <- read.baselines() +x <- bibliometric(bib, quant, 'GEOSCIENCES') +publist <- apply( + cbind(bib$pubs, + citation_rank(bib, quant = quant$GEOSCIENCES)), + 1, format_pub, au = + bib$au) +bib$ref +bib$au +``` + + + +## Indicators + +```{r biblioplot, cairo-scatter, echo=FALSE, message=FALSE, warning=FALSE, fig.width=12, fig.height=4} +biblioplot(bib, quant = quant$GEOSCIENCES) +``` + + +## Table + +\begin{table}[h] +\centering +\begin{tabular}{llll} +\hline +Publications (total) & Pubs. (as lead author) & Years & Pubs. per year \\ +`r x$pubs` & `r x$lead` & `r x$years` & `r x$pubs_year` \\ +\hline +Citations (total) & Citations per year & Citations per pub & Citations (highest pub) \\ +`r x$cit_tot` & `r x$cit_year` & `r x$cit_art` & `r x$cit_max` \\ +\hline +h-index & h-index per year & g-index & g-index per year \\ +`r x$hin` & `r x$hin_year` & `r x$gin` & `r x$gin_year` \\ +\hline +Pubs $>$q0.9 & Pubs $>$q0.9 (as lead) & i-score & i-score (as lead) \\ +`r x$pubs09` & `r x$pubs09_lead` & `r x$iscore` & `r x$iscore_lead` \\ +\hline +\end{tabular} +\end{table} + + +# Publication list + +\begin{enumerate} +`r publist` +\end{enumerate} + + +\end{document}