SOME NOTES ON R FACILITIES FOR USE IN ASSIGNMENT 2 Sorting: sort(x) Takes a vector and returns it in sorted order order(x) Takes a vector and returns the vector of indexes that would make it sorted. So x[order(x)] produces the same result as sort(x) Covariance matrices: cov(X) Returns the sample covariance matrix of data in X, which has one case per line and one column per variable. Logistic regression: m = glm(y~X,family="binomial",maxit=1000) Fits a logistic regression model for the binary responses in the vector y, using the covariates in the matrix X. An intercept term is also included in the model (so there's no need for X to have a column of all 1s). The result is a "model" object that can be used with the functions below. The "maxit" option tells it to try harder to find the solution (the default is a bit small). print(m) OR print(summary(m)) Displays information on a model fit with glm. coef(m) Returns the regression coefficients found by fitting a model with glm. The first coefficient is the intercept. Plotting: You can make scatterplots with classes in different colours (based on 0/1 class values) with a command like this: plot(x.train[,1],x.train[,2],pch=20,col=c("blue","red")[1+t.train])