{"word_count": 300, "character_count": 3189}
The job of Bishop of Rome - i.e. the Pope - is considered to be a life-long commitment. I mean, it usually was. There have been 266 popes since 32 A.D. (according to http://oce.catholic.com/...): almost all popes have served until their death. But that does not mean that they were in the job for long... One can easily extract the data from the website,&#62; L2=scan("http://oce.catholic.com/index.php?title=List_of_Popes",what="character")Read 4485 items&#62; index=which(L2=="&#60;/td&#62;&#60;td&#62;Reigned")&#62; X=L2[index+1]&#62; Y=strsplit(X,split="-")But one should work a little bit because sometimes, there are inconsistencies, e.g. 911-913 and then 913-14, so we need some more lines. Further, we can extract from this file the years popes started to reign, the year it ended, and the length, using those functions&#62; diffyears=function(x){+ s=NA+ if(sum(substr(x,1,1)=="c")&#62;0){x[substr(x,1,1)=="c"]=substr(x[substr(x,1,1)=="c"],3,nchar(x[substr(x,1,1)=="c"]))}+ if(length(x)==1){s=1}+ if(length(x)==2){s=diff(as.numeric(x))}+ return(s)}&#62; whichyearsbeg=function(x){+ s=NA+ if(sum(substr(x,1,1)=="c")&#62;0){x[substr(x,1,1)=="c"]=substr(x[substr(x,1,1)=="c"],3,nchar(x[substr(x,1,1)=="c"]))}+ if(length(x)==1){s=as.numeric(x)}+ if(length(x)==2){s=as.numeric(x)[1]}+ return(s)}&#62; whichyearsend=function(x){+ s=NA+ if(sum(substr(x,1,1)=="c")&#62;0){x[substr(x,1,1)=="c"]=substr(x[substr(x,1,1)=="c"],3,nchar(x[substr(x,1,1)=="c"]))}+ if(length(x)==1){s=as.numeric(x)}+ if(length(x)==2){s=as.numeric(x)[2]}+ return(s)}On our file, we have&#62; Years=unlist(lapply(Y,whichyearsbeg))&#62; YearsB=c(Years[1:91],752,Years[92:length(Years)])&#62; YearsB[187]=1276&#62; Years=unlist(lapply(Y,whichyearsend))&#62; YearsE=c(Years[1:91],752,Years[92:length(Years)])&#62; YearsE[187]=1276&#62; YearsE[266]=2013&#62; YearsE[122]=914 &#62; W=unlist(lapply(Y,diffyears))&#62; W=c(W[1:91],1,W[92:length(W)])&#62; W[W==-899]=1&#62; which(is.na(W))[1] 187 266&#62; W[187]=1&#62; W[266]=2013-2005If we plot it, we have the following graph,&#62; plot(YearsB,W,type="h")and if we look at the average length, we have the following graph,&#62; n=200&#62; YEARS = seq(0,2000,length=n)&#62; Z=rep(NA,n)&#62; for(i in 2:(n-1)){+ index=which((YearsB&#62;YEARS[i]-50)&#38;(YearsE&#60;YEARS[i]+50))+ Z[i] = mean(W[index])}&#62; plot(YEARS,Z,type="l",ylim=c(0,30))&#62; n=50&#62; YEARS = seq(0,2000,length=n)&#62; Z=rep(NA,n)&#62; for(i in 2:(n-1)){+ index=which((YearsB&#62;YEARS[i]-50)&#38;(YearsE&#60;YEARS[i]+50))+ Z[i] = mean(W[index])}&#62; lines(YEARS,Z,type="l",col="grey")which does not reflect mortality improvements that have been observed over two millenniums. It might related to the fact that the average age at time of election has  increased over time (for instance, Benedict XVI was elected at 78 - one of the oldest to be elected). Actually, serving a bit more than 7 years is almost the median,&#62; mean(W&#62;=7.5)[1] 0.424812(42% of the Popes did stay at least 7 years in charge) or we can look at the histogram,&#62; hist(W,breaks=0:35)Unfortunately, I could not find more detailed database (including the years of birth for instance) to start a life-table of Popes.&#160;