Useful R functions for the homework assignments: --- Basics --- Reading Data: * data = read.csv("filename.csv") loads in a csv file * str( data ) displays what factors are in the data * attach( data ) lets you access the factors by just their name Data Visualization and Manipulation: Suppose that we have factors called foo and bar (that have already been attached) * plot( data ) will plot all pairs of factors against each other. Quantitative factors will be plotted as points, boxplots will be used for * plot( foo , bar ) will plot foo against bar (just the two variables) * boxplot( foo , bar ) will boxplot foo with bar as the category labels * foo will bring up all the data values for foo * foo[ bar == value ] will provide the values of foo for datapoints that have bar == value. Getting Help: * help( "cmd" ) will pull up help docs on the command --- Tests --- * t.test( ... ) will run t-tests * prop.test( ... ) will run proportion z-tests --- Linear Regression --- * fit = lm( foo ~ bar , ... ) will do a linear regression fit to predict foo based on bar. If you wanted to do a fit with some other factor baz as well, you could do fit = lm( foo ~ bar + baz , ... ). If you wanted to transform the data, it's a little clearer to do the transform first: lbar = log( bar ), fit = lm( foo ~ lbar ). * summary( fit ) will give you the statistics on the fit (confidence intervals for the parameters, ANOVA) * fit$residuals will give you the residuals for the fit (you can use similar syntax to access the coefficients, etc.)