image

I managed to invoke R from Python and that too to check Ziff’s law

I populated the log frequency and log rank in to 2 lists and then tested this code

y_r =[] x_r =[] rank = 1 for freq, word in t : if freq > 2 : y_r.append(math.log(freq)) x_r.append(math.log(rank)) rank+=1

from rpy import r

print r.lsfit(x_r,y_r)[‘coefficients’]

It gave –0.78 , the same coefficient that I found in the NY TIMES article wow..its fantastic,…I am loving it