Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(tidyverse)
- library(janitor)
- library(broom)
- data541 <- read.csv("unit_541_practice_data.csv")
- data541 %>% View()
- groups <- data541 %>%
- group_by(group) %>%
- summarise_at(vars(happy),
- list(means = mean))
- model <- data541 %>% lm(happy ~ group, .)
- # create dummy variables
- data541$group_dummy_1 <- ifelse(data541$group == "Group 1", 1, 0)
- data541$group_dummy_2 <- ifelse(data541$group == "Group 2", 1, 0)
- data541$group_dummy_3 <- ifelse(data541$group == "Group 3", 1, 0)
- # create a linear model where 3 is the reference category
- data541 %>% lm(happy ~ group_dummy_1 + group_dummy_2, .) %>% summary
- # ANOVA
- model %>%
- anova() %>%
- tidy()
- summary(model)
- # Unit 551
- data551 <- read.csv("unit_551_practice_data.csv")
- data551 %>% View()
- # boxplot
- data551 %>%
- ggplot(aes(x = method, y = bacteria)) +
- geom_boxplot()
- # linear model
- data551$method <- as.factor(data551$method)
- model2 <- data551 %>%
- lm(bacteria ~ method, data = .)
- summary(model2)
- # ANOVA
- model2 %>%
- anova() %>%
- tidy()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement