# File / Change dir #nacteni souboru heartdisease <- read.table("heartdisease.txt", header=TRUE,sep=",") ### A retrospective sample of males in a heart-disease high-risk region ### of the Western Cape, South Africa. There are roughly two controls per ### case of CHD. Many of the CHD positive men have undergone blood ### pressure reduction treatment and other programs to reduce their risk ### factors after their CHD event. In some cases the measurements were ### made after these treatments. These data are taken from a larger ### dataset, described in Rousseauw et al, 1983, South African Medical ### Journal. ### ### sbp systolic blood pressure ### tobacco cumulative tobacco (kg) ### ldl low densiity lipoprotein cholesterol ### adiposity ### famhist family history of heart disease (Present, Absent) ### typea type-A behavior ### obesity ### alcohol current alcohol consumption ### age age at onset ### chd response, coronary heart disease #promenne, zakladni popis head(heartdisease) summary(heartdisease) #aktivujeme ramec attach(heartdisease) #kategorizace promennych sbp.kat <- cut(sbp,c(0,120,140,160,180,Inf),right=F,labels=c("Normotenze","Prehypertenze","Hypertenze I","Hypertenze II","Hyp. krize")) obes.kat <- cut(obesity,c(0,20,25,30,Inf),right=F,labels=c("Podvaha","Normalni","Nadvaha","Obezita")) #POPIS PROMENNYCH #kvalitativni promenne #tabulka sbp.table <- table(sbp.kat) sbp.table prop.table(sbp.table) #graf barplot(sbp.table) pie(sbp.table) #kvantitativni promenne hist(sbp) qqnorm(sbp) #VZTAHY MEZI PROMENNYMI # 2 kvalitativni #tabulka sbpobes.table <- table(sbp.kat,obes.kat) sbpobes.table prop.table(sbpobes.table,2) #graf barplot(sbpobes.table,beside=T,legend.text=rownames(sbpobes.table)) par(mar=c(5, 4, 4, 10) + 0.1) barplot(prop.table(sbpobes.table,2),xlab="Telesna hmotnost",ylab="Zastoupeni - krevni tlak",legend.text=rownames(sbpobes.table),args.legend = list(x = 7,y=0.9)) mosaicplot(sbpobes.table) # 2 kvantitativni plot(adiposity,obesity) pairs(heartdisease) # kvalitativni vs. kvantitativni par(mfrow=c(1,2)) boxplot(sbp~obes.kat) stripchart(sbp~obes.kat,vertical = TRUE,method = "jitter")