#commands for session 1 #reading in data, and summarizing it # two ways to read the same file ex <- read.table("example-pheno.csv", sep=",", header=TRUE) ex.b <- read.csv("example-pheno.csv") # or reading directly from the web # (remember to log on to ULiege first) read.table("http://faculty.washington.edu/kenrice/sisg/example-pheno.csv", sep=",") # reading the text file version of the same thing ex2 <- read.table("example-pheno.txt", header=TRUE) # use of is.na() - are values missing? table( is.na(ex2$bmi) ) # which data point is the missing one? # (with >1 missing, you'd get a vector # listing all the missing values) which( is.na(ex2$bmi) ) # get rid of it! keepme <- !is.na(ex2$bmi) ex2.nice <- ex2[keepme,] str(ex2.nice) #another wat str( subset(ex2, !is.na(bmi) ) ) ex2 <- ex2[,c(1,3,5,4,2)] str(ex2)