
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

Function Description read_csv("path/nhanes.csv") Read nhanes.csv in the path/ folder ( readr ) View(df) View tabular data frame df in a graphical viewer head(df) ; tail(df) Print first and last few rows of data frame df mean, median, range Descriptive stats. Remember na.rm=TRUE if desired is.na(x) Returns TRUE/FALSE if NA. sum(is.na(x)) to count NAs filter(df, ..,) Filters data frame according to condition ... (dplyr) t.test(y~grp, data=df) T-test mean y across grp in data df wilcox.test(y~grp, data=df) Wilcoxon rank sum / Mann-Whitney U test lmfit <- lm(y~x1+x2, data=df) Fit linear model y against two x ’s anova(lmfit) Print ANOVA table on object returned from lm() summary(lmfit) Get summary information about a model fit with lm() TukeyHSD(aov(lmfit)) ANOVA Post-hoc pairwise contrasts xt <- xtabs(~x1+x2, data=df) Cross-tabulate a contingency table addmargins(xt) Adds summary margin to a contingency table xt prop.table(xt) Turns count table to proportions (remember margin=1) chisq.test(xt) Chi-square test on a contingency table xt fisher.test(xt) Fisher’s exact test on a contingency table xt mosaicplot(xt) Mosaic plot for a contingency table xt factor(x, levels=c("wt", "mutant")) Create factor specifying level order relevel(x, ref="wildtype") Re-level a factor variable glm(y~x1+x2, data=df, family="binomial") Fit a logistic regression model power.t.test(n, power, sd, delta) T-test power calculations power.prop.test(n, power, p1, p2) Proportions test power calculations tidy() augment() glance() Model tidying functions in the broom package