内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用
虽然代码仍然正常工作,但是有什么方法可以解决警告呢?
dateset = subset(all_data[,c("VAR1","VAR2","VAR3","VAR4","VAR5","RATE1","RATE2","RATE3")]) dateset = cbind(dateset[c(1,2,3,4,5)],stack(dateset[,-c(1,2,3,4,5)]))
警告:
Warning message: In data.frame(..., check.names = FALSE) : row names were found from a short variable and have been discarded
你的data.frame
有row.names
:
A <- data.frame(a = c("A", "B", "C"), b = c(1, 2, 3), c = c(4, 5, 6), row.names=c("A", "B", "C")) cbind(A[1], stack(A[-1])) # a values ind # 1 A 1 b # 2 B 2 b # 3 C 3 b # 4 A 4 c # 5 B 5 c # 6 C 6 c # Warning message: # In data.frame(..., check.names = FALSE) : # row names were found from a short variable and have been discarded