Open Yuval-OS opened 1 month ago
See this reproducible code: It works without a function, but when used inside a function it says it cannot find data_obj. When I define data_obj in the global directory, it works fine.
requireNamespace("fwildclusterboot") data(voters)
feols_fit <- feols(proposition_vote ~ treatment + ideology1 + log_income | Q1_immigration, data = voters) boot1 <- boottest(feols_fit, B = 9999, param = "treatment", clustid = "group_id1") summary(boot1)
boot_func <- function(data_obj) { feols_fit1 <- feols(proposition_vote ~ treatment + ideology1 + log_income | Q1_immigration, data = data_obj) boot1 <- boottest(feols_fit1, B = 9999, param = "treatment", clustid = "group_id1") return(summary(boot1)) }
boot_func(voters) data_obj <- voters boot_func(voters)
See this reproducible code: It works without a function, but when used inside a function it says it cannot find data_obj. When I define data_obj in the global directory, it works fine.
requireNamespace("fwildclusterboot") data(voters)
feols_fit <- feols(proposition_vote ~ treatment + ideology1 + log_income | Q1_immigration, data = voters) boot1 <- boottest(feols_fit, B = 9999, param = "treatment", clustid = "group_id1") summary(boot1)
boot_func <- function(data_obj) { feols_fit1 <- feols(proposition_vote ~ treatment + ideology1 + log_income | Q1_immigration, data = data_obj) boot1 <- boottest(feols_fit1, B = 9999, param = "treatment", clustid = "group_id1") return(summary(boot1)) }
boot_func(voters) data_obj <- voters boot_func(voters)