过滤功能dplyr似乎无法正常工作

时间:2017-09-26 23:36:13

标签: r dataframe filter dplyr

让我们假设我在R-Studio中加载了一个名为exprCore1的data.fram,df如下所示:

   measure qid value
1   p5      1   0.2
2   p100    1   0.8
3   map     1   0.22
4   p5      2   0.4
5   p100    2   0.5
6   map     2   0.32

基本上所有想要的是测量方法为“map”的每一列。

我尝试了不同的方法,所有这些方法只返回一个没有内容的0x4 tibble。

到目前为止我尝试了什么:

library("dplyr", lib.loc="~/R/win-library/3.4")
exprCore1MapOverall <- dplyr::filter(exprCore1, measure == "map")

这只会返回:

# A tibble: 0 x 4
# ... with 4 variables: measure <chr>, queryID <chr>, value <dbl>, coreTag <chr>

我在这里缺少什么?谁能帮我?

谢谢

编辑:

也试过

exprCore1MapOverall <-filter(exprCore1, measure %in%c("map"))

Edit2:

我无法发布整个data.frame,以及大量数据的方式。我用

缩小了它
exprCore1Fixed <- exprCore1[-c(30: 142082),]

这是exprCore1Fixed的输入

structure(list(measure = c("num_ret        ", "num_rel        ", 
"num_rel_ret    ", "map            ", "R-prec         ", "bpref          ", 
"recip_rank     ", "ircl_prn.0.00  ", "ircl_prn.0.10  ", "ircl_prn.0.20  ", 
"ircl_prn.0.30  ", "ircl_prn.0.40  ", "ircl_prn.0.50  ", "ircl_prn.0.60  ", 
"ircl_prn.0.70  ", "ircl_prn.0.80  ", "ircl_prn.0.90  ", "ircl_prn.1.00  ", 
"P5             ", "P10            ", "P15            ", "P20            ", 
"P30            ", "P100           ", "P200           ", "P500           ", 
"P1000          ", "num_ret        ", "num_rel        ", "ircl_prn.0.70  ", 
"ircl_prn.0.80  ", "ircl_prn.0.90  ", "ircl_prn.1.00  ", "P5             ", 
"P10            ", "P15            ", "P20            ", "P30            ", 
"P100           ", "P200           ", "P500           ", "P1000          "
), queryID = c("1", "1", "1", "1", "1", "1", "1", "1", "1", "1", 
"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", 
"1", "1", "1", "1", "2", "2", "all", "all", "all", "all", "all", 
"all", "all", "all", "all", "all", "all", "all", "all"), value = c(752, 
5, 4, 0.1089, 0.2, 0.8, 0.25, 0.25, 0.25, 0.25, 0.1429, 0.1429, 
0.1429, 0.1429, 0.0342, 0.0342, 0, 0, 0.2, 0.1, 0.0667, 0.1, 
0.1, 0.03, 0.02, 0.008, 0.004, 2, 3, 0.0696, 0.0565, 0.0374, 
0.0345, 0.25, 0.1962, 0.1718, 0.151, 0.1192, 0.0525, 0.0335, 
0.0164, 0.0097), coreTag = c("Core_1", "Core_1", "Core_1", "Core_1", 
"Core_1", "Core_1", "Core_1", "Core_1", "Core_1", "Core_1", "Core_1", 
"Core_1", "Core_1", "Core_1", "Core_1", "Core_1", "Core_1", "Core_1", 
"Core_1", "Core_1", "Core_1", "Core_1", "Core_1", "Core_1", "Core_1", 
"Core_1", "Core_1", "Core_1", "Core_1", "Core_1", "Core_1", "Core_1", 
"Core_1", "Core_1", "Core_1", "Core_1", "Core_1", "Core_1", "Core_1", 
"Core_1", "Core_1", "Core_1")), .Names = c("measure", "queryID", 
"value", "coreTag"), row.names = c(NA, -42L), class = c("tbl_df", 
"tbl", "data.frame"))

1 个答案:

答案 0 :(得分:1)

使用

listofdata.txt

做了这个伎俩,非常感谢你。