0
我回到了我上個月編寫的一些R代碼,但似乎我使用的reshape版本(0.8.4,R 2.15.2)改變了這個功能。reshape ::用data.frame中的字符融化意外的行爲
這裏有一個例子:
> library(reshape)
> so.test <- data.frame(
one = as.character(rnorm(750)),
two = as.character(rnorm(750)),
three = as.character(rnorm(750)), four = as.character(rnorm(750)))
> check <- melt(so.test)
Using one, two, three, four as id variables
這使等於原來的一個data.frame:
> table(so.test == check)
TRUE
3000
我也有reshape2 ::融化試過,但我得到了相同的結果。有趣的是,melt()
功能工作原理與數值的data.frame預期:
> so.test2 <- data.frame(
one = rnorm(750),
two = rnorm(750),
three = rnorm(750), four = rnorm(750))
> check2 <- melt(so.test2)
Using as id variables
> head(check2)
variable value
1 one 0.2471168
2 one -0.0663480
3 one -0.0251867
4 one 2.8786207
5 one -0.2586785
6 one -0.7508927
你是對的,必須是我的代碼上游的bug。它的塑造是那些日子之一...... – Stedy