Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

data.table method #12

Open
medewitt opened this issue Nov 3, 2020 · 1 comment
Open

data.table method #12

medewitt opened this issue Nov 3, 2020 · 1 comment
Labels

Comments

@medewitt
Copy link

medewitt commented Nov 3, 2020

I've run into an issue where I have to convert data.table objects to data.frames in order for the rules to be applied.

library(data.table)
library(magrittr)
library(dcmodify)

dt_women <- as.data.table(women)

m <- modifier( if (height < mean(height)) height <- 2*height
, if ( weight > mean(weight) ) weight <- weight/2  )
dt_out <- modify(dt_women,m)
df_out <- modify(women,m)

sum(delta_out <- dt_out$weight - df_out$weight)

Output:

527

It looks like the methods aren't picking up the second class of the data.table objects

@markvanderloo
Copy link
Member

Yes, this is a property of S4 dispatch, so the only way to do it right now is indeed to convert explicitly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants