Open krlmlr opened 10 years ago
You might want to look at tidyr...
Thanks, I wasn't aware of tidyr
. I see that gather()
has a convert
parameter, but according to the code and the docs it doesn't seem to apply to the current use case. I propose to fix the type of the value
column, i.e., to coerce it to a given type, while convert = TRUE
will call type.convert()
on the key
column.
Perhaps tidyr::gather()
could also benefit from fixing the value of the type column.
This is kind of the opposite to #51. In
melt
, thevalue
column is coerced tocharacter
if only one of themeasure.vars
is acharacter
. Perhaps it would make sense to introduce a parameter that specifies the desired output type, and to warn if such coercion happens. Something likemelt(d, coerce = as.numeric)
ormelt(d, target_type = "numeric")
would substitute values that cannot be coerced withNA
(with a warning) and turn off the warning that value types are mixed.