Quick Reference Table

Table 8 Common Tasks Quick Reference

Task

Function(s)

Example

Import CSV

read.csv()

d <- read.csv('data/AppRating.csv')

Check structure

str(), head()

str(d); head(d, 10)

Remove NAs

complete.cases()

d_clean <- d[complete.cases(d), ]

Basic summary

summary()

summary(d$score)

Create histogram

ggplot() + geom_histogram()

ggplot(d, aes(x=score)) + geom_histogram()

One-sample t-test

t.test()

t.test(d$score, mu = 3)

Two-sample t-test

t.test()

t.test(score ~ platform, data = d)

One-way ANOVA

aov()

fit <- aov(score ~ group, data = d)

Linear regression

lm()

mod <- lm(rating ~ price, data = d)

Check residuals

plot()

plot(mod, which = 1:2)