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

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -