# a brief introduction to some R commands # learn about R, download R from http://www.r-project.org/ # there are many nice R introductions on the web, one that I like is at: http://www.statmethods.net/index.html ls() # shows the objects in the current workspace name <- c("Hamb","Chsbrg","Delxbg","Fish","Chix") # create a new object sizeg <- c(107, 121, 216, 156, 223) totfat <- c(9, 13, 31, 25, 20) burgers <- data.frame(Name=name,sizeg,totfat) # create a data frame rm(name, sizeg, totfat) # remove objects when they are not needed burgers plot(burgers$sizeg,burgers$totfat,xlab="total size",ylab="fat",main="Size vs fat") # the $ sign is used to identify a variable in a data frame summary(burgers) # here we read in data from a file burgers2 <- read.table("c:/temp/burgs1.txt",header=T) # here we read in a comma-separated value (CSV) file saved from Excel student1 <- read.csv("c:/temp/student2.csv",na.strings = ".",header=T) student1 plot(student1$Dias1,student1$Sys1) # Note that objects are case-sensitive table(student1$Eye) table(student1$Eye,student1$Thumb) tapply(student1$Sys1,student1$Eye,mean) # calculates the mean value for Sys1 separately for each value of Eye