You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
melt() works as expected melt(in.df, id.vars=c(1))
But my dataframe has duplicated (non-unique) column names names(in.df) <- c("AA","BB","BB")
This doesn't do what I want melt(in.df, id.vars=c("AA"))
So, I use indexing (rather than renaming the columns). melt(in.df, id.vars=c(1), measure.vars=c(2,3))
The dimensions are as expected, contents are not.
Should melt_check() abort if measure.vars names are not unique? if(length(measure.vars) != length(unique(measure.vars))) { stop("names of measure variables are not unique: ", vars, call. = FALSE) }
Thanks again for creating an essential tool.
The text was updated successfully, but these errors were encountered:
Hadley et al.,
As a regular user of the excellent
reshape2
package, the following behavior ofmelt()
surprised me:Simple dataframe:
in.df <- data.frame(AA=c(1,2,3), BB=c(10,11,12), CC=c(13,14,15))
melt()
works as expectedmelt(in.df, id.vars=c(1))
But my dataframe has duplicated (non-unique) column names
names(in.df) <- c("AA","BB","BB")
This doesn't do what I want
melt(in.df, id.vars=c("AA"))
So, I use indexing (rather than renaming the columns).
melt(in.df, id.vars=c(1), measure.vars=c(2,3))
The dimensions are as expected, contents are not.
Should
melt_check()
abort ifmeasure.vars
names are not unique?if(length(measure.vars) != length(unique(measure.vars))) { stop("names of measure variables are not unique: ", vars, call. = FALSE) }
Thanks again for creating an essential tool.
The text was updated successfully, but these errors were encountered: