我想知道是否可以将一行从表的底部移动到顶部。当我使用到目前为止的代码时,
dt[nrow(dt)+1,] <- rbind(c("","","1X","1X","1X","1X","1X","1X","1X","1X","1X","1X","1X","1X","1X","1X","1X","1X","2X","6X","3X",""), dt)
table
使用此代码,我在表格底部获得了一个新行。如果我将“+1”更改为“-22”,该行将移至 table 2 的顶部。如果我进行此更改,则会从表格底部删除一行。任何有关为什么会发生这种情况的帮助将不胜感激。
最佳答案
有几种方法,但这里有两个简单的方法:
a <- data.frame(x = 1:10, y = 20:29)
a <- a[c(10,1:9),]
a
##Or
a <- data.frame(x = 1:10, y = 20:29)
a <- rbind(a[10,],a[1:9,])
a
关于r - 将行移到表格顶部,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/45423160/