Skip to content

Instantly share code, notes, and snippets.

@aaronsaunders
Created August 9, 2013 08:08
Show Gist options
  • Save aaronsaunders/6191943 to your computer and use it in GitHub Desktop.
Save aaronsaunders/6191943 to your computer and use it in GitHub Desktop.
colSums( x, na.rm= FALSE, dims= 1)
rowSums( x, na.rm= FALSE, dims= 1)
colMeans(x, na.rm= FALSE, dims= 1)
rowMeans(x, na.rm= FALSE, dims= 1)
rowsum(x, group, reorder= TRUE) # finds row sums for each level of a grouping variable
apply(X, MARGIN, FUN, ...) # applies the function (FUN) to either rows (1) or columns (2) on object X
apply(x, 1, min) # finds the minimum for each row
apply(x, 2, max) # finds the maximum for each column
col.max(x) # another way to find which column has the maximum value for each row
which.min(x)
which.max(x)
z <- apply(big5r, 1, which.min) # tells the row with the minimum value for every column
cor(x, y, use="pair") # correl. matrix for pairwise complete data, use="complete" for complete cases
aov(x~y, data=datafile) # where x and y can be matrices
aov.ex1 <- aov(DV~IV, data=data.ex1) # do the analysis of variance or
aov.ex2 <- aov(DV~IV1*IV21, data=data.ex2) # do a two way analysis of variance
summary(aov.ex1) # show the summary table
print(model.tables(aov.ex1, "means"), digits=3) # report the means and the number of subjects/cell
boxplot(DV~IV, data=data.ex1) # graphical summary appears in graphics window
lm(x~y, data=dataset) # basic linear model where x and y can be matrices (see plot.lm for plotting options)
t.test(x, g)
pairwise.t.test(x, g)
power.anova.test(groups = NULL, n = NULL, between.var = NULL,
within.var = NULL, sig.level = 0.05, power = NULL)
power.t.test(n = NULL, delta = NULL, sd = 1, sig.level = 0.05,
power = NULL, type = c("two.sample", "one.sample", "paired"),
alternative = c("two.sided", "one.sided"),strict = FALSE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment