我正在使用melt
并遇到以下警告消息:
attributes are not identical across measure variables; they will be dropped
环顾四周有人提到这是因为变量是不同的类;但是,我的数据集并非如此。
这是数据集:
test <- structure(list(park = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L), .Label = c("miss", "piro", "sacn", "slbe"), class = "factor"),
a1.one = structure(c(3L, 1L, 3L, 3L, 3L, 3L, 1L, 3L, 3L,
3L), .Label = c("agriculture", "beaver", "development", "flooding",
"forest_pathogen", "harvest_00_20", "harvest_30_60", "harvest_70_90",
"none"), class = "factor"), a2.one = structure(c(6L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L), .Label = c("development",
"forest_pathogen", "harvest_00_20", "harvest_30_60", "harvest_70_90",
"none"), class = "factor"), a3.one = structure(c(3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L), .Label = c("forest_pathogen",
"harvest_00_20", "none"), class = "factor"), a1.two = structure(c(3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L), .Label = c("agriculture",
"beaver", "development", "flooding", "forest_pathogen", "harvest_00_20",
"harvest_30_60", "harvest_70_90", "none"), class = "factor"),
a2.two = structure(c(6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
6L), .Label = c("development", "forest_pathogen", "harvest_00_20",
"harvest_30_60", "harvest_70_90", "none"), class = "factor"),
a3.two = structure(c(3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L), .Label = c("forest_pathogen", "harvest_00_20", "none"
), class = "factor")), .Names = c("park", "a1.one", "a2.one",
"a3.one", "a1.two", "a2.two", "a3.two"), row.names = c(NA, 10L
), class = "data.frame")
这是结构:
str(test)
'data.frame': 10 obs. of 7 variables:
$ park : Factor w/ 4 levels "miss","piro",..: 1 1 1 1 1 1 1 1 1 1
$ a1.one: Factor w/ 9 levels "agriculture",..: 3 1 3 3 3 3 1 3 3 3
$ a2.one: Factor w/ 6 levels "development",..: 6 6 6 6 6 6 6 6 6 6
$ a3.one: Factor w/ 3 levels "forest_pathogen",..: 3 3 3 3 3 3 3 3 3 3
$ a1.two: Factor w/ 9 levels "agriculture",..: 3 3 3 3 3 3 3 3 3 3
$ a2.two: Factor w/ 6 levels "development",..: 6 6 6 6 6 6 6 6 6 6
$ a3.two: Factor w/ 3 levels "forest_pathogen",..: 3 3 3 3 3 3 3 3 3 3
是因为每个变量的级别数不同吗?那么,在这种情况下我可以忽略警告信息吗?
要生成警告消息:
library(reshape2)
test.m <- melt (test,id.vars=c('park'))
Warning message:
attributes are not identical across measure variables; they will be dropped
谢谢。