R:删除向量的最后一个元素 [英] R: removing the last elements of a vector
本文介绍了R:删除向量的最后一个元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何删除动物园系列的最后100个元素?
How can I remove the last 100 elements of a zoo series?
我知道名称[-element]表示法
,但我无法用它减去一个完整的部分
I know the name[-element] notation but I can't get it work to substract a full section
推荐答案
我喜欢为此使用 head
,因为它更易于输入。尽管其他方法可能执行得更快...但是我很懒,而我的计算机却不是。 ;-)
I like using head
for this because it's easier to type. The other methods probably execute faster though... but I'm lazy and my computer is not. ;-)
x <- head(x,-100)
> head(1:102,-100)
[1] 1 2
这篇关于R:删除向量的最后一个元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文