筛选器功能dplyr似乎不起作用

编程入门 行业动态 更新时间:2024-10-10 13:24:15
本文介绍了筛选器功能dplyr似乎不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

Let's presume I have a data.fram called exprCore1 loaded in R-Studio, the df looks like this:

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"的每一列.

Basically all want is every column in which the measurement method is "map".

我尝试了不同的方法,所有这些方法仅返回不带内容的0x4小标题.

I tried different approaches, all of them just return only a 0x4 tibble without content.

到目前为止我尝试过的:

What I tried so far:

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>

我在这里想念什么?谁能帮我?

What am I missing here? Can anyone help me?

谢谢

也尝试过

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

Edit2:

我无法发布整个data.frame,也无法发布大量数据.我用

I cant post the whole data.frame, way to much data. I shrunk it using

exprCore1Fixed <- exprCore1[-c(30: 142082),]

这是exprCore1Fixed的输出

Here is the dput of 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"))

推荐答案

使用

dplyr::filter(exprCore1, trimws(measure) == "map")

成功了,非常感谢.

更多推荐

筛选器功能dplyr似乎不起作用

本文发布于:2023-10-30 18:27:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1543653.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不起作用   功能   dplyr

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!