x <-2 | assigns a value to x |
x <- c(1,2,3,4) | assigns a vector to x |
rm(x) | removes x |
data <- read.table("filepath/", header="TRUE") | reads data from a file |
data <- read.csv("filepath/.csv", header="TRUE") | reads data from a .csv file |
min(x) | minimum |
max(x) | maximum |
sum(x) | sum |
mean(x) | mean |
sd(x) | standard deviation |
boxplot(data) | boxplot |
hist(data) | histogram |
plot(y~x) | scatterplot of the values of y based on x |
fit <-(y~x, data=datafile) | predict y based on x (simple linear regression) |
plot(fit) | plots residuals |
summary(fit) | slopes, p-values, R^2 and standard error |
confint(fit) | confidence intervals |
predit.lm(fit,newdata=data.frame(x=10),interval="prediction",level=.99) | 99% prediction interval for y values where x=10 |
predit.lm(fit,newdata=data.frame(x=10),interval="confidence",level=.99) | 99% confidence for the average/prediction when x=10 |
AIC(fit) | Akaike information criterion gives AIC values for a model lower AIC or BIC indicates the model is a better fit for the data |
BIC(fit) | Bayesian information criterion favors simpler models, penalizes model complexity to a higher degree than AIC |