library(foreign)
library(dplyr)
data_URL <- "https://github.com/mca91/EconometricsWithR/blob/master/data/fastfood.dta?raw=true"
dat <- read.dta(data_URL)
dat <- dat %>%
mutate(FTE = nmgrs + empft + (0.5 * emppt),
FTE2 = nmgrs2 + empft2 + (0.5 * emppt2))
# generate the subsets
# compute the group means
# generate the subsets
dat_NJ <- subset(dat, state == 1)
dat_PA <- subset(dat, state == 0)
# compute the group means
dat %>%
group_by(state) %>%
summarise(mean(FTE, na.rm = T),
mean(FTE2, na.rm = T))
ex() %>% check_predefined_objects("dat")
ex() %>% check_object("dat_NJ") %>% check_equal(undefined_msg = "You have not defined `dat_NJ`!")
ex() %>% check_object("dat_PA") %>% check_equal(undefined_msg = "You have not defined `dat_NJ`!")
ex() %>% check_or(
ex() %>% check_output_expr("dat %>%
group_by(state) %>%
summarise(mean(FTE, na.rm = T),
mean(FTE2, na.rm = T))", missing_msg = "It seems that not all group means have been correctly printed to the console."),
ex() %>% check_output_expr("mean(dat_NJ$FTE, na.rm=T);mean(dat_NJ$FTE2, na.rm = T);mean(dat_PA$FTE, na.rm = T);mean(dat_PA$FTE2, na.rm = T)", missing_msg = "It seems that not all group means have been correctly printed to the console.")
)
success_msg(msg = "Corect!")