Move row to top of table

前端 未结 1 1574
说谎
说谎 2021-01-19 14:29

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(\"\",\"\",\"         


        
相关标签:
1条回答
  • 2021-01-19 14:34

    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
    
    0 讨论(0)
提交回复
热议问题