# session 2 commands # 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) plot(salary~year, data=sal) plot(salary~jitter(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) # Q4 library("MASS") search() # it's loaded, and the 2nd place R will look for objects plot(brain~body, mammals) plot(brain~body, mammals, log="xy") plot(log(brain)~log(body), mammals) # get x and y co-ordinates for wherever you click locator() # add text to points you click near # (right click to stop it) identify(log(mammals$body),log(mammals$brain),labels=row.names(mammals))