按列表中元素的长度过滤
我正在尝试按列表中元素的总长度进行过滤。我有一个根据大小不同长度不同的鱼的列表(每条鱼都有一个唯一的 ID 示例 Ring20_4)。
有没有办法过滤列表以仅包含达到或超过一定长度的鱼?
我尝试按数据集中的距离进行过滤,但不在列表中进行过滤。
I am trying to filter by the total length of an element in a list. I have a list of fish that have different lengths based on their size (each fish has a unique ID Example Ring20_4).
Is there a way to filter the list to only include fish at or above a certain length?
I have tried to filter by the distance in a dataset but not in a list.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在示例尝试中,您可以使用过滤功能:
假设您需要过滤“距离”,或者您可以选择任何其他变量;
使用与您类似的玩具数据:
现在使用 lapply 和您选择的函数或 dplyr 来保持简单:
给出:
on a sample try you can you lapply with a filter function :
Assuming you need to filter on "Distance" or you can pick any other variable of choice;
With toy data similar to yours:
Now use lapply with function of your choice or dplyr to keep it simple:
gives:
您可以使用
subset
而无需定义匿名函数;只需在逗号后陈述您的逻辑条件即可。您可以使用例如Distance >= 152
。也许您还希望列表中的数据框在距离上相似;为此,您可以使用
Reduce
找出所有的相交
。数据:
You may use
subset
without needing to define an anonymous function; just state your logical condition after a comma. You could use e.g.Distance >= 152
.Maybe you also want the data frames in the list to be similar in Distance; for this you could find out the
intersect
of all usingReduce
.Data: