And so begins English Composition I

[This article was first published on Fellgernon Bit - rstats, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

This week started the English Composition I: Achieving Expertise course (Comer, 2013) that I have been looking forward to.

I am not sure yet how long I will last, but I hope to enjoy it as much as I can. Plus, it should help me with my posting and other writing areas. While I last in the course, I plan to publish my writings in the blog too. So you will hopefully see me be more active here.

As it is important to cite when writing, I have also figured out how to do so automatically in Rmd files. For that I learnt how to use knitcitations from the GitHub instructions (knitcitations) and a explanatory post (Boettiger, 2013).

knitcitations is great, but it kind of struggles with some pages. That is why I modified my template in FBit by writing my own citing function for pages where citep fails. Here is the code:

<span class="c1">## I made my own citing function since citep() doesn't work like I want to with</span>
<span class="c1">## urls that are not really pages themselve like part of a GitHub repo.</span>
mycitep <span class="o"><-</span> <span class="kr">function</span><span class="p">(</span>x<span class="p">,</span> short<span class="p">,</span> year<span class="o">=</span>substr<span class="p">(</span>date<span class="p">(),</span> <span class="m">21</span><span class="p">,</span> <span class="m">24</span><span class="p">),</span> tooltip<span class="o">=</span><span class="kc">TRUE</span><span class="p">)</span> <span class="p">{</span>
    tmp <span class="o"><-</span> citep<span class="p">(</span>x<span class="p">)</span>
    res <span class="o"><-</span> gsub<span class="p">(</span><span class="s">"></a>"</span><span class="p">,</span> paste0<span class="p">(</span><span class="s">">"</span><span class="p">,</span> short<span class="p">,</span> <span class="s">"</a>"</span><span class="p">),</span> tmp<span class="p">)</span>
    <span class="kr">if</span><span class="p">(</span>tooltip<span class="p">)</span> <span class="p">{</span>
        res <span class="o"><-</span> gsub<span class="p">(</span><span class="s">"\\?\\?\\?\\?"</span><span class="p">,</span> year<span class="p">,</span> res<span class="p">)</span>
    <span class="p">}</span>
<span class="p">}</span>

<span class="c1">## You already saw an inline working example in the post itself.</span>

To leave a comment for the author, please follow the link and comment on their blog: Fellgernon Bit - rstats. offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)