gpt4 book ai didi

R:根据R中大数据集中列中的值删除行

转载 作者:行者123 更新时间:2023-12-04 00:05:42 25 4
gpt4 key购买 nike

这个问题在这里已经有了答案:





Filter data.frame rows by a logical condition

(9 个回答)


4年前关闭。




我正在 R 中研究 104500 个观察值的数据集。我想根据具有值“TX”和“NY”的列名“state”删除行。

我正在使用以下代码

customers <- customers[customers$State != "TX"]

我收到以下错误

Error: Length of logical index vector must be 1 or 11 (the number of rows), not 104541



任何人都可以帮我解决这个问题吗?

最佳答案

我想你最后错过了一个逗号。

customers <- customers[customers$State != "TX", ]
^

因此,您可以根据过滤器和所有列选择行。

HTH

下次请提供一个可重现的例子。

关于R:根据R中大数据集中列中的值删除行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46574230/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com