# attach the package and load the dataset
# obtain an overview over the dataset
# verify that Guns is a balanced panel
years <-
states <-
# attach the `AER` package and load the `Guns` dataset
library(AER)
data("Guns")
# obtain an overview over the dataset
summary(Guns)
# verify that `Guns` is a balanced panel
years <- length(levels(Guns$year))
states <- length(levels(Guns$state))
years*states == nrow(Guns)
ex() %>% check_library("AER")
test_function("data")
test_or({
ex() %>% check_function("summary") %>% check_result() %>% check_equal()
},{
f <- ex() %>% override_solution("str(Guns)")
f %>% check_function("str") %>% check_result() %>% check_equal()
})
ex() %>% check_object("years") %>% check_equal()
ex() %>% check_object("states") %>% check_equal()
ex() %>% check_function("nrow") %>% check_arg("x") %>% check_equal()
test_or({
test_student_typed("years*states == nrow(Guns)")
},{
test_student_typed("states*years == nrow(Guns)")
},{
test_student_typed("nrow(Guns) == years*states")
},{
test_student_typed("nrow(Guns) == states*years")
})
success_msg("Correct! There are 51 states (entities) over observed over 23 years (time periods). The product of the number of entities and equals the number of total observations in the dataset.")