R sweep-equivalent with integer division -
is there way use sweep(dataframe)
integer division, or equivalent such?
this minimal example of sweep
not using integer division - want replace integer division:
sweep(x = mtcars, margin = 2, stats = unlist(mtcars[1,]), fun = '/')
some limitations need stick to:
- i need preserve column names of dataframe, done in example above.
- i cannot use
round
,floor
,ceil
, or similar - needs equivalent of integer division (floor
have different effects on negative numbers integer division). - if possible, i'd prefer not store information in additional variables during process.
- i'm dealing relatively large dataframe, turn out slow solutions might not option here.
does know way of achieving in r?
pass '%/%' function, integer division. see arithmetic operator docs.
sweep(x = mtcars, margin = 2, stats = unlist(mtcars[1,]), fun = '%/%')
Comments
Post a Comment