# graphing distributions of single variables # get data # http://www.robin-beaumont.co.uk/virtualclassroom/book2data/pain_medication.dat mydataframe <- read.delim("http://www.robin-beaumont.co.uk/virtualclassroom/book2data/pain_medication.dat", header=TRUE) names(mydataframe) # or locally # mydataframe <- read.delim("D:\\web_sites_mine\\HIcourseweb new\\book2data\\pain_medication.dat", header=TRUE) names(mydataframe) str(mydataframe) names(mydataframe) #[1] "age" "gender" "health" "treatment" "dosage" "status" #[7] "time" with(mydataframe, Hist(age, scale="frequency", breaks="Sturges", col="darkgray")) #density plots library(car) densityPlot( ~ time, data=mydataframe, bw="SJ", adjust=1, kernel="gaussian") densityPlot( ~ age, data=mydataframe, bw="SJ", adjust=1, kernel="gaussian") # avoiding the use of the car package; plot( density ( mydataframe$age)) plot( density ( mydataframe$time))