Put Google Scholar citations on your personal website with R, scholar, ggplot2 and cron

[This article was first published on Bart Rogiers, 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.

I have been looking for a solution to put my Google Scholar citations on my personal website for quite some time now. Some apps/gadgets seem to have existed to do so (e.g. citations-gadget), but none seem to be functioning today because of changes at Google Scholar, and embedding your entire profile page won’t work either. Basically, I had given up my search for a solution, until a few months ago, I discovered a blog post on the R scholar package by James Keirstead (development is taking place on github).
For installing the R scholar package (and its dependencies) in Linux, it is possible you need to install the following packages first (I was running Linux Lite 2.0 on my personal laptop and had to do so):
sudo apt-get install libcurl4-openssl-dev libxml2-dev
Then install the R package using the conventional
in R. After loading the package, you can get the citation history from a Google Scholar profile page (citations per year, as displayed in the bar plot on the right-hand side of the page) using a single function call on the Google Scholar profile ID. Getting the data, and making a plot with the ggplot2 package, which contains a timestamp, is done as follows:
  cit <- get_citation_history('u421gfwAAAAJ')
    xlab('Year of citation')+
    ylab('Google Scholar\n cites')+
    annotate('text',label=format(Sys.time(), "%Y-%m-%d %H:%M:%S %Z"),x=-Inf,y=Inf,vjust=1.5,hjust=-0.05,size=3,colour='gray')
With my own humble contribution to science, the resulting image is something like this:
Now, for the automation of this image creation task, you can save the above code as an R script, and simply use cron in Linux. To set up your task with crontab, use
crontab -e
in the terminal and add a single line of text with the instructions to run your script. If you want to execute the script hourly, all you have to do is add a line like this:
0 * * * * cd /home/your/folder && Rscript your_script.R
and save the file. If you do this in a publicly accessible folder, or you can make the image itself publicly accessible (options to do so are Google Drive, Ubuntu One, Dropbox, etc.), you can easily embed it on your personal website with an HTML tag. I currently have it set up like this, so it updates every hour when my personal laptop is switched on. The up-to-date version of the plot above should be online here. Not so hard after all! 🙂

To leave a comment for the author, please follow the link and comment on their blog: Bart Rogiers.

R-bloggers.com 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)