方法 1:
df1<-data.frame(A=1:5,B=2:6)
df2<-data.frame(A=1:5,B=2:6)
df3<-rbind(df1,df2)
row.names(df3)
[1] "1" "2" "3" "4" "5" "6" "7" "8" "9" "10"
方法 2:
df1<-data.frame(matrix(data = c(1:5,2:6),
nrow = 5,
dimnames = list(c(1:5),c("A","B"))))
df2<-data.frame(matrix(data = c(1:5,2:6),
nrow = 5,
dimnames = list(c(1:5),c("A","B"))))
df3<-rbind(df1,df2)
row.names(df3)
[1] "1" "2" "3" "4" "5" "11" "21" "31" "41" "51"
我理解行名应该是唯一的值,我想知道为什么方法 1 和方法 2 会在行名中产生不同的结果?