Introduction
Earlier this year I was pleased to stumble on to Petr Keil's Simple template for scientific manuscripts in Rmarkdown and the Github Repo https://github.com/petrkeil/Blog/tree/master/2015_03_12_R_ms_template.
I was already using Rmarkdown effectively for everything I wanted except my bibliography, and this helped a lot. But I eventually found I needed to tweak the format of the citation style. I tried out a bunch of other CSL files but none felt just right. I tried out these after downloading from https://github.com/citation-style-language/styles:
american-physiological-society.csl
annals-of-the-association-of-american-geographers.csl
biomed-central.csl
ecology.csl
pnas.csl
SO I hacked the CSL file
- I used the
american-physiological-society.csl
to get stuff I wanted and pasted into themee.csl
- get the files from this link /rmarkdown_utils/CitationsInRmarkdown.Rmd
- get the files from this link /rmarkdown_utils/meemodified.csl
- get the files from this link /rmarkdown_utils/refs.bib
NB also that the csl file in petrkeil’s repo is an older version from 2012 of the version in the citation-style repo called methods-in-ecology-and-evolution
. The differences are not large though.
1.1.1 Example 1:
The journal article by Michener et al. (1997) and another one (Bodnar et al. 2004) appear with their full URL even though I just want their DOI.
1.1.2 Example 2:
Some recent papers (Open Science Collaboration 2015; Aiken et al. 2015; Davey et al. 2015) don’t have Volume info and I want to say [epub ahead of print].
1.1.3 Example 3:
This blog post on ‘evidence based data analysis pipeline’ by Peng (2013) is one that definitely needs the URL and date accessed.
References
Aiken, A.M., Davey, C., Hargreaves, J.R. & Hayes, R.J. (2015). Re-analysis of health and educational impacts of a school-based deworming programme in western Kenya: a pure replication. International Journal of Epidemiology, dyv127. Retrieved from http://ije.oxfordjournals.org/content/early/2015/07/21/ije.dyv127.full http://www.ije.oxfordjournals.org/lookup/doi/10.1093/ije/dyv127
Bodnar, A., Castorina, R., Desai, M., Duramad, P., Fischer, S., Klepeis, N., Liang, S., Mehta, S., Naumoff, K., Noth, E.M., Schei, M., Tian, L., Vork, K.L. & Smith, K.R. (2004). Lessons learned from ‘the skeptical environmentalist’: an environmental health perspective. International journal of hygiene and environmental health, 207, 57–67. Retrieved from http://www.sciencedirect.com/science/article/pii/S1438463904702643
Davey, C., Aiken, A.M., Hayes, R.J. & Hargreaves, J.R. (2015). Re-analysis of health and educational impacts of a school-based deworming programme in western Kenya: a statistical replication of a cluster quasi-randomized stepped-wedge trial. International Journal of Epidemiology, dyv128. Retrieved from http://ije.oxfordjournals.org/content/early/2015/07/21/ije.dyv128.full http://www.ije.oxfordjournals.org/lookup/doi/10.1093/ije/dyv128
Michener, W.K., Brunt, J.W., Helly, J.J., Kirchner, T.B. & Stafford, S.G. (1997). Nongeospatial metadata for the ecological sciences. Ecological Applications, 7, 330–342. Retrieved from http://www.scopus.com/inward/record.url?scp=0030616825\&partnerID=8YFLogxK
Open Science Collaboration. (2015). Estimating the reproducibility of psychological science. Science, 349, aac4716–aac4716. Retrieved from http://www.sciencemag.org/cgi/doi/10.1126/science.aac4716
Peng, R.D. (2013). Implementing Evidence-based Data Analysis: Treading a New Path for Reproducible Research. Simply statistics. Retrieved July 26, 2015, from http://simplystatistics.org/2013/09/05/implementing-evidence-based-data-analysis-treading-a-new-path-for-reproducible-research-part-3/
# first replace the <macro name="access">
# with
<macro name="access">
<choose>
<if variable="DOI"/>
<!--don't use if there is a DOI-->
<else>
<choose>
<if variable="URL">
<group delimiter=" " prefix=" ">
<group>
<text variable="URL"/>
</group>
<group prefix="[" suffix="]" delimiter=" ">
<date variable="accessed">
<date-part name="day"/>
<date-part name="month" prefix=" " suffix=" " form="short"/>
<date-part name="year"/>
</date>
</group>
</group>
</if>
</choose>
</else>
</choose>
</macro>
#### Then add this ####
<macro name="date">
<choose>
<if variable="issued">
<choose>
<if type="article-journal">
<date variable="issued">
<date-part name="year"/>
</date>
</if>
<else>
<date variable="issued">
<date-part name="year"/>
</date>
</else>
</choose>
</if>
<else>
<text term="no date" prefix="[" suffix="]"/>
</else>
</choose>
</macro>
#### And add this ####
<else-if type="article-journal">
<choose>
<if variable="issue volume" match="any">
<text macro="title" suffix=" "/>
<text variable="container-title" suffix=" " form="short" font-style="italic" strip-periods="true"/>
<text variable="volume"/>
<text variable="page" prefix=": "/>
<text macro="date" prefix=", " suffix="."/>
</if>
<else>
<choose>
<if variable="DOI">
<text macro="title" suffix=" "/>
<text variable="container-title" suffix=" " form="short" font-style="italic"/>
<group prefix="(" suffix=").">
<date variable="issued">
<date-part name="month" prefix=" " suffix=" "/>
<date-part name="day" suffix=", "/>
<date-part name="year"/>
</date>
</group>
<text variable="DOI" prefix=" doi: "/>
</if>
<else>
<text variable="container-title" suffix=". " form="short" font-style="italic"/>
</else>
</choose>
</else>
</choose>
</else-if>
Now use this modified csl in the header of the RMD file instead of mee.csl
1.2 NEW References
Aiken, A.M., Davey, C., Hargreaves, J.R. & Hayes, R.J. (2015).Re-analysis of health and educational impacts of a school-based deworming programme in western Kenya: a pure replication International Journal of Epidemiology (epub ahead of print July 2015). doi: 10.1093/ije/dyv127
Bodnar, A., Castorina, R., Desai, M., Duramad, P., Fischer, S., Klepeis, N., Liang, S., Mehta, S., Naumoff, K., Noth, E.M., Schei, M., Tian, L., Vork, K.L. & Smith, K.R. (2004).Lessons learned from ‘the skeptical environmentalist’: an environmental health perspective. International journal of hygiene and environmental health 207: 57–67, 2004.
Davey, C., Aiken, A.M., Hayes, R.J. & Hargreaves, J.R. (2015).Re-analysis of health and educational impacts of a school-based deworming programme in western Kenya: a statistical replication of a cluster quasi-randomized stepped-wedge trial International Journal of Epidemiology (epub ahead of print July 2015). doi: 10.1093/ije/dyv128
Michener, W.K., Brunt, J.W., Helly, J.J., Kirchner, T.B. & Stafford, S.G. (1997).Nongeospatial metadata for the ecological sciences Ecological Applications 7: 330–342, 1997. http://www.scopus.com/inward/record.url?scp=0030616825\&partnerID=8YFLogxK
Open Science Collaboration. (2015).Estimating the reproducibility of psychological science Science 349: aac4716–aac4716, 2015.
Peng, R.D. (2013). Implementing Evidence-based Data Analysis: Treading a New Path for Reproducible Research. Simply statistics. http://simplystatistics.org/2013/09/05/implementing-evidence-based-data-analysis-treading-a-new-path-for-reproducible-research-part-3/ [26 Jul. 2015]