R:删除向量的最后一个元素
如何删除动物园系列的最后 100 个元素?
我知道名称[-元素]符号 但我无法减去完整的部分
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
如果你是单人航班
if you're a one liner
为了完整起见,另一行话:
Another one-liner for the sake of completeness:
我喜欢使用
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. ;-)实际上,还有一种更快的方法:
代码显示:
Actually, there's a much faster way:
Code show:
我敢打赌
length<-
是修剪向量的最有效方法:I bet
length<-
is the most efficient way to trim a vector:只需使用数字索引,即
您需要确保
N
大于 100 等Just use the numeric indices, ie
where you should need to ensure
N
is larger 100 etc