Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Everyone that authors an R package is curious about how many users download it. As far as I know there’s still no way to get information on all the downloads, from all the R mirrors. Here I’m using package cranlogs, which only gives information on the downloads from the R Studio mirror. It also does not allow to now from where in the world these downloads were made. However, it has a major advantage: speed! The package cranlogs provides a easy (and way faster) method to get this information without having to download all the log files (which can take a long time).

I have written this little script, which I use to keep track of my packages’ downloads (here I’m using MetaLandSim as an example).

First of all let’s load all the required R packages:

#install.packages("cranlogs")
library(cranlogs)
library(ggplot2)

#Last week's downloads
##         date count     package
## 1 2019-03-30     7 MetaLandSim
## 2 2019-03-31     7 MetaLandSim
## 3 2019-04-01    11 MetaLandSim
## 4 2019-04-02    30 MetaLandSim
## 5 2019-04-03    30 MetaLandSim
## 6 2019-04-04    19 MetaLandSim
## 7 2019-04-05    11 MetaLandSim

#How many overall downloads

sum(mls[,2])

## [1] 21868

#Plot
gr0 <- ggplot(mls2, aes(mls2$date, mls2$count)) +
geom_line(colour = "red",size=1)
labs(title = paste0("MetaLandSim daily downloads ", Sys.Date()-1)) 

#Cumulative
cumulative <- cumsum(mls[,2])
mls2 <- cbind(mls,cumulative)

#Plot
gr1 <- ggplot(mls2, aes(mls2$date, mls2$cumulative)) +
geom_line(colour = "blue",size=1)
labs(title = paste0("MetaLandSim cumulative downloads until ", Sys.Date()-1))