# chapter 2 of Dalgaard rm(list=ls()) # install.packages("ISwR") library(ISwR) head(thuesen) ?thuesen dim(thuesen) search() # not in .GlobalEnv, so finding it in ISwR package data(thuesen) # now there is a promise in .GlobalEnv dim(thuesen) # now that it is used, it actually brings it in and knows more about it thue4 <- within(thuesen,{ log.gluc <- log(blood.glucose) m <- mean(log.gluc) centered.log.gluc <- log.gluc - m rm(m) # get rid of objects not wanted in dataframe }) head(thue4) # new cols are in alphabetical order plot(thue4,gap=0) # arg sent out to plot.data.frame # use of mtext x <- runif(50,0,2) y <- runif(50,0,2) plot(x, y, main="Main title", sub="subtitle", xlab="x-label", ylab="y-label") text(0.6,0.6,"text at (0.6,0.6)") text(1,1,"+",cex=2,font=2) text(1,1,"text1at (1,1)",pos=1) text(1,1,"text2at (1,1)",pos=2) text(1,1,"text3at (1,1)",pos=3) text(1,1,"text4at (1,1)",pos=4) abline(h=.6,v=.6) for (side in 1:4) mtext(-1:4,side=side,at=.7,line=-1:4) mtext(paste("side",1:4), side=1:4, line=-1,font=c(2,3)) x=rnorm(100) hist(x, freq=F) s <- sd(x) m <- mean(x) curve(dnorm(x,m,s), add=T) # in curve, x is the default x-axis variable name, not x from above