本文介绍了将行移到表格顶部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以从表格的底部到顶部移动一行。当我使用到目前为止的代码时,

I am wondering if it is possible to move one row from bottom to top of a table. When I use the code I have so far,

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)

。如果进行此更改,则会从表底部删除一行。

tableWith this code, I get a new row at the bottom of my table. If I change the "+1" to "-22" the row goes to the top of the table 2. If I make this change, a row gets deleted off of the bottom of my table. Any help with why this might be happening would be appreciated.

推荐答案

有几种方法,但是有两种简单的方法:

There are a few ways but here are two easy ones:

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

这篇关于将行移到表格顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 00:37