[This article was first published on One R Tip A Day, 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.
Ravi from this post (via Revolutions blog) wanted to check the code that produces the left panel of the Figure 3 from this article taken from the current issue of the R Journal. Below my attempt to reproduce the plot:Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
rv <- seq(1.3, 2.9, .1)
rv <- rv[-grep("1.6", rv)] # remove R version 1.6
pckg.num <- c(110,129,162,219,273,357,406,548,647,739,911,1000,1300,1427,1614,1952)
rv.dates <- c("2001-6-21", "2001-12-17","2002-06-12","2003-05-27",
"2003-11-16","2004-06-05","2004-10-12","2005-06-18","2005-12-16", "2006-05-31",
"2006-12-12","2007-04-12","2007-11-16","2008-03-18","2008-10-18","2009-09-17")
pckg.fit <- lm(pckg.num~rv)
png("CRAN_packages.png")
par(mar=c(7, 5, 5, 3), las=2)
plot(as.POSIXct(rv.dates), pckg.num, xlab="",ylab="",col="red", log="y", pch=19, axes=F)
axis.POSIXct(1, 1:16, rv.dates, format="%Y-%m-%d")
mtext("Date", side=1, line=5, las=1)
axis(2, at=c(100,200,300,400,500,600,800,100,1200,1500,2000))
mtext("Number of CRAN Packages", side=2, line=3, las=3)
axis.POSIXct(3, rv.dates, rv.dates, labels=as.character(rv))
mtext("R Version", side=3, line=3, las=1)
axis(4, pckg.num)
abline(v=as.POSIXct(rv.dates), col="lightgray", lty="dashed")
abline(h=pckg.num, col="lightgray", lty="dashed")
box()
abline(lm(log10(pckg.num)~as.POSIXct(rv.dates)), col="red")
dev.off()
To leave a comment for the author, please follow the link and comment on their blog: One R Tip A Day.
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.