library(openxlsx) df<-read.xlsx("http://kanggc.iptime.org/book/data/finance-k.xlsx") df_dat<-data.matrix(df) year<-df_dat[,1] jj<-df_dat[,18] jj bins<-c(22,26,30,34,38,42) bins class<-cut(jj,breaks=bins) class table(class) transform(table(class),Rel_Freq=prop.table(Freq)) hist(jj, breaks=bins, xlim=c(22,42))