R: removing the last elements of a vector

后端 未结 6 1265
梦如初夏
梦如初夏 2021-01-31 07:36

How can I remove the last 100 elements of a zoo series?

I know the name[-element] notation but I can\'t get it work to substract a full section

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-31 08:07

    I bet length<- is the most efficient way to trim a vector:

    > x <- 1:10^5
    > length(x)
    [1] 100000
    > length(x) <- 3
    > x
    [1] 1 2 3
    

提交回复
热议问题