This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
r-tutorial [2011/10/13 00:07] liuyipei |
r-tutorial [2011/10/15 12:05] (current) liuyipei [Problem Set 1 Hints] |
||
---|---|---|---|
Line 18: | Line 18: | ||
dim(cars) | dim(cars) | ||
- | plot(x=cars$speed, | + | plot(x=cars$speed, |
| | ||
| | ||
Line 280: | Line 280: | ||
- | ====Basics==== | + | ====Problem Set 1 Hints and Other Tricks==== |
+ | < | ||
+ | setwd('/ | ||
+ | dz< | ||
+ | head(dz) | ||
+ | |||
+ | cd1< | ||
+ | colnames(cd1)< | ||
+ | cd1$chole< | ||
+ | head(cd0) | ||
+ | |||
+ | cd0< | ||
+ | cd0$chole< | ||
+ | cd.table< | ||
+ | head(cd1) | ||
+ | head(cd0) | ||
+ | head(cd.table) | ||
+ | |||
+ | q1.table <- merge(cd.table, | ||
+ | q1.table$hifreq <- ifelse(q1.table$freq > 0.1, ' | ||
+ | head(q1.table) | ||
+ | nrow(q1.table) | ||
+ | ncol(q1.table) | ||
+ | |||
+ | sum(q1.table$chole == ' | ||
+ | sum(q1.table$chole == ' | ||
+ | table(q1.table$chole, | ||
+ | |||
+ | library(plyr) | ||
+ | hard.work< | ||
+ | c(nrow(x), ncol(x), x$chole[1]==' | ||
+ | } | ||
+ | ddply(q1.table, | ||
+ | head(lets.talk.about.what.happened) | ||
+ | dim(lets.talk.about.what.happened) | ||
+ | summary(lets.talk.about.what.happened) | ||
+ | colnames(lets.talk.about.what.happened)< | ||
+ | |||
+ | library(caTools) | ||
+ | my.x< | ||
+ | my.y< | ||
+ | plot(my.x, my.y) | ||
+ | trapz(my.x, my.y) | ||
+ | |||
+ | data.frame(a=c(8, | ||
+ | t | ||
+ | fisher.test(t)-> | ||
+ | ls(f.t) | ||
+ | f.t$p.value | ||
+ | f.t$conf.int | ||
+ | |||
+ | </ |