jmpsteen / medflex

Flexible mediation analysis using natural effect models in R
23 stars 6 forks source link

fix problem when working with tbl_df objects data.frames from popular… #3

Closed jlegewie closed 8 years ago

jlegewie commented 8 years ago

… dplyr package

medflex doesn't play well with tbl_df data.frames from the popular dplyr package. The pull request fixes that at least in one location. There might be problems at other places too but at least this error disappears. Probably all syntax like data[, ONEVARIABLE] doesn't work. data[[VARIABLE]] solves the problem

# the example from the paper works fine
impFit <- glm(UPB ~ factor(attbin) + negaff + gender + educ + age, family = binomial("logit"), data = UPBdata)
expData <- neImpute(impFit)
# when the dataset is first converted with tbl_df, neImpute doesn't work
impFit <- glm(UPB ~ factor(attbin) + negaff + gender + educ + age, family = binomial("logit"), data = tbl_df(UPBdata))
expData <- neImpute(impFit)
jmpsteen commented 8 years ago

Thanks for this. I've adopted your patch, made some additional changes and added you as a contributor to the package :+1: