## January 25, Section 1 ## ## Some functions in R: c(1,7:9) # c() concatenates everything in the parentheses into a vector vec = c(1,7:9) vec str(vec) # str() gives details of what's in parens. data type, size, elements summary(vec) # gives summary statistics of vector data(iris) # dataset iris is loaded (this dataset comes with R) iris edit(iris) # manually edit the data names(iris) # list column names of data set summary(iris) # a more interesting summary of dataset # download APPENC01.txt from website first <- read.table("c:/413/APPENC01.txt", header=F) # read in rectangular dataset names(first) #names are V1, V2, etc first<-edit(first) # change column names manually names(first) # see that it worked first$Something # Shows the column named "Something" first$V3 summary(first$Something) par(mfrow=c(1,3)) # Let two figures be shown in the same row inside one window. # make some histograms hist(first$Something,xlab="Length of Stay",main="SENIC Project") # R chooses bins hist(first$Something, breaks=seq(4,20,by=4),xlim=c(0,25),ylim=c(0,90),xlab="Length of Stay",main="SENIC Project") hist(first$Something, breaks=6.5:20.5,xlim=c(0,25),ylim=c(0,40),xlab="Length of Stay", main="SENIC Project") # look at help(hist) for more options # Note: We can save or copy this figure (to go into homework reports). attach(first) # So we don't have to write first$Something all of the time. Something # Now, "Something" is its own thing.