-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
level order for melt.array #19
Comments
That's the default with |
As I understand it, |
Ah, good point - I only checked with arrays that already had sorted names. It would be helpful if you could contribute a couple of examples of expected behaviour. |
A bit convoluted but: data <- matrix(rnorm(40), ncol=4, dimnames=list(paste0("S", 1:10), paste0("1", c("", "0", "00", "000"), "g/ml")))
df <- melt(data, varnames=c("Sample", "Concentration"))
# default:
ggplot(df, aes(x=Concentration, y=value))+geom_point()
# ordered as in the matrix:
df$Concentration <- factor(df$Concentration, levels=colnames(data))
ggplot(df, aes(x=Concentration, y=value))+geom_point() |
Here's a slightly simpler case: library(reshape2)
data <- matrix(1:12, c(3, 4))
dimnames(data) <- list("x" = letters[3:1], y = LETTERS[4:1])
str(melt(data)) |
* upstream/master: (70 commits) corrected argument to `install_github` Add note to NEWS Handle 'no measure.variables' case; closes hadley#46 Bump version Fix license typo Bump version Add r cmd check notes Tweak news Code outside link, not inside :( Re-document Use new testthat structure Preserve order of dimnames. Closes hadley#19 Update urls Use dcast, not cast, in recast. Closes hadley#45 Depend on plyr 1.8.1. Closes hadley#44 Make sure OBJECT bit is set when 'value' is a factor Update NEWS Use $ instead of [[ Include updated args in melt_check roxygen Some more tweaks + robustness ... Conflicts: DESCRIPTION man/guess_value.Rd man/margins.Rd man/melt.array.Rd
Since arrays row/column/... order can be meaningful, it would be nice to have an option in melt.array to be able to have the levels of factors generated from dimnames to be in the original array order.
The text was updated successfully, but these errors were encountered: