Right now, this doesn't work as a way to shuffle the rows.
using TidierData
using StatsBase
@chain df begin
@slice(sample(1:n(), n())
end
There are two issues here:
@slice() doesn't allow functions to be run inside of it
n() may or may not be parsed correctly here.
We need to support functions within @slice(). We may also want to define a local function n() within the @slice() macro that returns nrow() to ensure that n() can be used in functions inside of @slice().
This is not an immediate priority but we should come back to this because it may allow for a simpler implementation of @slice_sample() in the future.
Right now, this doesn't work as a way to shuffle the rows.
There are two issues here:
@slice()
doesn't allow functions to be run inside of itn()
may or may not be parsed correctly here.We need to support functions within
@slice()
. We may also want to define a local functionn()
within the@slice()
macro that returnsnrow()
to ensure thatn()
can be used in functions inside of@slice()
.This is not an immediate priority but we should come back to this because it may allow for a simpler implementation of
@slice_sample()
in the future.