Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 如何测试包含多个值之一的行?_R - Fatal编程技术网

R 如何测试包含多个值之一的行?

R 如何测试包含多个值之一的行?,r,R,有没有更快的方法来完成以下内容?我想测试30个不同的值,而不仅仅是下面显示的3个 保持在%中使用% 当然,最好的方法是,如果有一种模式,它就是你想要保留的: tests = seq(from = 36081004500, length.out = 30, by = 200) keeps = cost[cost$GEO.id2 %in% tests, ] 在介绍性R资源中,查找使用match和%In%函数的示例。不要忘记在逻辑测试后使用逗号。此时,您可能要选择第一列而不是所需的行。 tests

有没有更快的方法来完成以下内容?我想测试30个不同的值,而不仅仅是下面显示的3个

保持在%中使用%

当然,最好的方法是,如果有一种模式,它就是你想要保留的:

tests = seq(from = 36081004500, length.out = 30, by = 200)
keeps = cost[cost$GEO.id2 %in% tests, ]

在介绍性R资源中,查找使用match和%In%函数的示例。不要忘记在逻辑测试后使用逗号。此时,您可能要选择第一列而不是所需的行。
tests = seq(from = 36081004500, length.out = 30, by = 200)
keeps = cost[cost$GEO.id2 %in% tests, ]