# 1. přednáška 7. října 2013 # rm(list=ls()) # x = c(1,3,8) (xMean = mean(x)) (xMed = median(x)) # data(Kojeni) attach(Kojeni) vekM hist(vekM,breaks=seq(17,38,by=3),col="yellow") hist(vekM,breaks=seq(17,38,by=3)+0.5,col="yellow") (h =hist(vekM,seq(17,38,by=3)+0.5,plot=FALSE)) (n = nrow(Kojeni)) cbind(h$mids,h$counts,h$counts/n,cumsum(h$counts),cumsum(h$counts)/n) cbind("xj*"=h$mids,"nj"=h$counts,"fj"=h$counts/n, "Nj"=cumsum(h$counts),"Nj/n"=cumsum(h$counts)/n) # data(tolary) tolary sort(tolary) hist(tolary,breaks=c(9:12,16,20,30,50)+0.5,col="yellow") (h=hist(tolary,breaks=c(9:12,16,20,30,50)+0.5,plot=FALSE)) h$density*99 # pořadí x = c(32, 25, 27, 25, 31, 23, 28) rbind(x,"pořadí Rj"=rank(x)) # medián (x = c(5, 3, 4, 9, 6)) sort(x) # median(vekM) quantile(vekM,probs=(1:3)/4) # KRABICOVÝ DIAGRAM fivenum(vekM) boxplot(vekM) boxplot(vekM,horizontal=TRUE,col="yellow") # quantile(tolary,probs=(0:4)/4) # V4 data(EU2010) EU2010$země V4 = c(3,14,18,23) EU2010$země[V4] HDP_V4 = EU2010[V4,c("země","obyvatel","HDP")] attach(HDP_V4) HDP mean(HDP) weighted.mean(HDP,w=obyvatel) # modus (nj = table(tolary)) which.max(nj) # kde je maximální četnost nj[which.max(nj)] # jaká je maximální četnost