R UseMethod(“选择方法”)中出错:没有适用于“选择方法”的方法应用于类为“NULL”的对象

R UseMethod(“选择方法”)中出错:没有适用于“选择方法”的方法应用于类为“NULL”的对象,r,rstudio,knitr,dplyr,r-markdown,R,Rstudio,Knitr,Dplyr,R Markdown,在将这个R标记编入HTML文件时,我遇到了一个奇怪的错误。我认为这与dplyr包与knitr的某种不兼容有关 更新:我用dplyr::bind_cols命令替换了cbind块,正如下面有人建议不要将cbind与dplyr一起使用。然而,我现在得到了一个不同的、同样无法理解的错误: 图书馆弹琴 counts.all eval->eval->bind\u cols->cbind\u all->呼叫 以前使用cbind而不是dplyr::bind_cols时出错: 单独运行块可以很好地工作,并且我能够

在将这个R标记编入HTML文件时,我遇到了一个奇怪的错误。我认为这与dplyr包与knitr的某种不兼容有关

更新:我用dplyr::bind_cols命令替换了cbind块,正如下面有人建议不要将cbind与dplyr一起使用。然而,我现在得到了一个不同的、同样无法理解的错误:

图书馆弹琴 counts.all eval->eval->bind\u cols->cbind\u all->呼叫

以前使用cbind而不是dplyr::bind_cols时出错:

单独运行块可以很好地工作,并且我能够很好地编织,直到我使用select from dplyr添加了最后一块

这是我得到的错误:

读取元数据。 为与dplyr兼容,请勿将单元格ID列指定为row.names

```{r}
meta <- read.delim("QC_metrics_SCell_SF10281_SF10282_SF10345_SF10360.txt", check.names = F, stringsAsFactors = F)
```
根据活/死/多个呼叫筛选单元格。 排除空、仅红色和多单元格井:

```{r, results='hide', message=FALSE, warning=FALSE}
library(dplyr)
meta.select <- filter(meta, grepl("^1g", `Live-dead_call`))
```
基于1000个基因阈值筛选细胞:

(Includes 12 'FAIL' cells)
```{r}
meta.select <- filter(meta.select, Genes_tagged > 1000)
```
子集计数表仅包括通过QC的单元格

```{r}
counts.select <- dplyr::select(counts.all, one_of(meta.select$ID))
head(counts.select[,1:10])
```

如果没有再现问题的数据,很难判断,但根据错误消息,它可能会计数。all为空,尽管cbind可能会导致select出现其他问题。要进行故障排除,请在创建该对象并注释掉dplyr::select行后返回类似headcounts.all的内容,同时了解发生了什么。感谢您的回复。您是对的-编制.all在HTML文件中返回NULL。但是,当我在运行cbind命令后在控制台中执行headcounts.all时,它会准确地返回它应该返回的值。为什么会这样?我应该用另一个命令替换cbind吗,也许是来自dplyr?我用dplyr::bind_cols替换了cbind命令,请参见更新。谢谢你的帮助!编辑:我替换了命令,但在编织时仍然出现错误。@marc_aragones:这是Rmarkdown,不是Markdown。请不要改变它。
```{r}
counts.all <- cbind(count.tables[["SF10281"]], count.tables[["SF10282"]], count.tables[["SF10345"]], count.tables[["SF10360"]])

write.table(counts.all, file="gliomaRawCounts_10281_10282_10345_10360.txt", sep="\t", quote=F, col.names=NA)
```
```{r}
meta <- read.delim("QC_metrics_SCell_SF10281_SF10282_SF10345_SF10360.txt", check.names = F, stringsAsFactors = F)
```
```{r, results='hide', message=FALSE, warning=FALSE}
library(dplyr)
meta.select <- filter(meta, grepl("^1g", `Live-dead_call`))
```
(Includes 12 'FAIL' cells)
```{r}
meta.select <- filter(meta.select, Genes_tagged > 1000)
```
```{r}
counts.select <- dplyr::select(counts.all, one_of(meta.select$ID))
head(counts.select[,1:10])
```