It works for me. I did the following.
library(reshape2)
tableMS <- read.table(text=' X Y Z T
1 375 855 455.7259 3777.856
2 395 969 347.8306 2506.7
3 449 811 309.9512 519.8513
4 451 774 278.291 717.8705
5 453 774 278.291 717.8705
6 455 774 278.291 717.8705
7 521 697 376.734 693.8541
8 529 855 455.7259 3777.856
9 531 855 455.7259 3777.856
10 609 774 278.291 717.8705',header=TRUE)
EDIT This still work even if you coerce Z
and T
to a list.
tableMS$Z <- as.list(tableMS$Z)
tableMS$T <- as.list(tableMS$T)
MeltTable <- melt(tableMS,id=c("X","Y"))
# MeltTable
# X Y variable value
# 1 375 855 Z 455.7259
# 2 395 969 Z 347.8306
# 3 449 811 Z 309.9512
# 4 451 774 Z 278.2910
# 5 453 774 Z 278.2910
# 6 455 774 Z 278.2910
# 7 521 697 Z 376.7340
# 8 529 855 Z 455.7259
# 9 531 855 Z 455.7259
# 10 609 774 Z 278.2910
# 11 375 855 T 3777.8560
# 12 395 969 T 2506.7000
# 13 449 811 T 519.8513
# 14 451 774 T 717.8705
# 15 453 774 T 717.8705
# 16 455 774 T 717.8705
# 17 521 697 T 693.8541
# 18 529 855 T 3777.8560
# 19 531 855 T 3777.8560
# 20 609 774 T 717.8705
edit don't work with reshape2 version 1.4.2
A workaround is to use data.table
package. BTW this solution is faster.
library(data.table)
tableMS$Z <- as.vector(as.list(tableMS$Z))
tableMS$T <- as.vector(as.list(tableMS$T))
setDT(tableMS)
melt(tableMS,id=c("X","Y"))