在R函数中可能是一个相当微不足道的错误 [英] Probably a fairly trivial error in an R function
本文介绍了在R函数中可能是一个相当微不足道的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在控制台中粘贴以下函数:
I am pasting in the console the following function:
mirna_counts <- function (wd) {
mirna_ensemble <- read.table("/Volumes/Data/nimr/lewis/edgeR/mirna_ensemble.txt", header =
TRUE, sep="\t")
setwd(wd)
all_counts <- read.table("accepted_hits_clean.count", sep="\t")
colnames(all_counts) <- c("Ensembl.Gene.ID", "counts")
mirna_clean_counts <- merge(x = mirna_ensemble, y = all_counts, by = "Ensembl.Gene.ID")
write.csv(mirna_clean_counts, file="mirna_clean_counts.csv", row.names = FALSE)
return c(sum(all_counts$counts), sum(mirna_clean_counts$counts))
}
我收到一条错误消息:
> mirna_counts <- function (wd) {
+ mirna_ensemble <- read.table("/Volumes/Data/nimr/lewis/edgeR/mirna_ensemble.txt", header = TRUE, sep="\t")
+ setwd(wd)
+ all_counts <- read.table("accepted_hits_clean.count", sep="\t")
+ colnames(all_counts) <- c("Ensembl.Gene.ID", "counts")
+ mirna_clean_counts <- merge(x = mirna_ensemble, y = all_counts, by = "Ensembl.Gene.ID")
+ write.csv(mirna_clean_counts, file="mirna_clean_counts.csv", row.names = FALSE)
+ return c(sum(all_counts$counts), sum(mirna_clean_counts$counts))}
Error: unexpected symbol in:
"write.csv(mirna_clean_counts, file="mirna_clean_counts.csv", row.names = FALSE)
return c"
如果我通过一行一行的方式执行函数的代码,而不是一切正常。这里出了什么问题 - 你能帮忙吗?
If I execute the code of the function by pasting line by line than everything is fine. What is going wrong here - can you help? It must be something fairly obvious that I am missing here.
推荐答案
在R中,你必须写 return(...)
- 包括括号应该可以解决你的问题。
In R, you have to write return(...)
- including the parentheses should fix your problem.
这篇关于在R函数中可能是一个相当微不足道的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文