#Cholesterol Data Analysis: #Read the data: cholesterol=read.table("cholesterol.txt",header=T) #Extract the variables: sex=cholesterol[,"SEX"] age=cholesterol[,"AGE"] tc=cholesterol[,"TC"] hdl=cholesterol[,"HDL"] trig=cholesterol[,"TRIGLYCERIDE"] ldl=cholesterol[,"LDL"] #Scatter plot of the data: plot(cholesterol) par(ask=T) par(mfrow=c(2,4)) #Boxplots: boxplot(tc~sex, main="TC") boxplot(hdl~sex, main="HDL") boxplot(trig~sex, main="TRIG") boxplot(ldl~sex, main="LDL") boxplot(tc~age) boxplot(hdl~age) boxplot(trig~age) boxplot(ldl~age) #Histograms: hist(tc) hist(hdl) hist(trig) hist(ldl) hist(log(tc)) hist(log(hdl)) hist(log(trig)) hist(log(ldl)) #Define new measures: new=100*log(hdl)/(log(hdl)+log(ldl)) #Plot new variable: par(mfrow=c(2,2)) hist(new) plot(hdl+ldl,new,main="new vs. old") boxplot(new~sex, main="NEW") boxplot(new~age, main="NEW") plot(hdl,new) plot(ldl,new) plot(tc,new) plot(trig,new) sink("CholesterolAnalysis.txt") #Get summary statistics: print(summary(cholesterol[,-1])) print(summary(new)) print(summary(lm(new ~ ldl+hdl))) print(summary(lm(new ~ tc))) print(summary(lm(new ~ trig))) sink()