R code for linear regression

To perform a linear regression as mentioned in the main article, simply copy and paste the script below into your R console once you have started up the program, and then modify it to analyse your own data.

rank<-seq(1,50,1)
freq<-c(22038615, 12545825, 10741073, 10343885, 10144200, 6996437, 6332195, 4303955, 3978265, 3872477, 3856916, 3430996, 3281454, 3081151, 2909254, 2683014, 2573587, 2485306, 1915138, 1885366, 1865580, 1820935, 1801708, 1776767, 1767638, 1712406, 1638830, 1635914, 1619007, 1490548, 1481869, 1379320, 1296879, 1181023, 1151045, 1083029, 1022775, 1018283, 992596, 969591, 933542, 925515, 919821, 892535, 892102, 874406, 857168, 829018, 824568, 795534)
plot(rank,freq,log="xy",xlab="Rank",ylab="Frequency")
xl<-log(rank)
yl<-log(freq)
est<-lm(yl~xl)
summary(est)
p<-predict(est)
px<-exp(p)
points(rank,px,type="l")

Back to the main article.