## Read in the crab data from the command line #a. using a downloaded copy #crab <- read.table("/Users/tathornt/crab.txt",header=TRUE) # on a Mac! crab <- read.table("C:\\Users\\kenrice\\Desktop\\SISG\\SISG-IntroR\\exercises\\crab.txt", header=TRUE) #b. from the course website crab2 <- read.table("http://faculty.washington.edu/kenrice/rintro/crab.txt",header=TRUE) 2. ## Cross-tabulate the color of the cribes and the number of satellites with(crab,table(color,n.satellites)) ## Can calculate the mean number of sattelites for a particular color with( subset(crab,color=="medium"), mean(n.satellites) ) with( subset(crab,color=="light medium"), mean(n.satellites) ) with( subset(crab,color=="dark medium"), mean(n.satellites) ) with( subset(crab,color=="dark"), mean(n.satellites) ) 3. ## Read in salary and identify the missing observations salary=read.table(file.choose(),header=TRUE) salary[is.na(salary$salary), ] ## Can also identify the missing observations using the following commands misnum=(1:19792)[is.na(salary$salary)] salary[misnum,] 4. # Read in the othercrab data set othercrab=read.csv("http://faculty.washington.edu/kenrice/rintro/othercrab.csv") # header=TRUE is default for read.csv()