# session 2 commands setwd( "C:/Users/Ken/Desktop/SISG/SISG-13/exercises" ) # first, read in the data; sal <- read.table("salary.dat", header=TRUE) # Q1 - some plots of variables (of different types) plot(year~salary, data=sal) dev.new() plot(salary~year, data=sal) plot(salary~jitter(year), data=sal) plot(salary~as.factor(year), data=sal) plot(salary~rank, data=sal) plot(field~rank, data=sal) plot(salary~gender, data=sal) # Q2 #conditioning plot; can year explain the M/F difference? library("lattice") bwplot(salary~gender|year,data=sal) #can rank explain it? (yes, mostly) plot(salary~interaction(gender,rank), data=sal, varwidth=TRUE) with(sal, table(interaction(gender,rank))) # Q4 library("MASS") search() # where does R look for objects? (and in what order?) plot(brain~body,data=mammals) plot(brain~body,data=mammals,log="xy") # get x and y co-ordinates for wherever you click locator() # add text to points you click near # (right click to stop it) identify(mammals$body,mammals$brain,labels=row.names(mammals))