【发布时间】:2021-09-24 08:52:17
【问题描述】:
我已经在 R 中编写了下面的 if 语句。它工作正常,但是有一个令人讨厌的警告消息,我 1) 不完全理解并且 2) 想要 不 得到。 :-)
关于1):什么意思
“警告信息:关闭未使用的连接 3”
在这种情况下,数字 (3) 是什么意思? 谷歌搜索找到了一些指针(How to fix error "closing unused connection" 和 Warning: closing unused connection n),它们似乎不起作用,但我知道:可能是我。我究竟做错了什么? 下面是我的代码。
谢谢!
砂光机
filetype = summary(file(opt$datagwas))$class
if(filetype == "gzfile"){
cat("\n* The file appears to be gzipped, checking delimiter now...")
TESTDELIMITER = readLines(opt$datagwas, n = 1)
cat("\n* Data header looks like this:\n")
print(TESTDELIMITER)
if(grepl(",", TESTDELIMITER) == TRUE){
cat("\n* Data is comma-seperated, loading...\n")
GWASDATA_RAW = fread(paste0("zcat < ",opt$datagwas),
header = TRUE, sep = ",", dec = ".",
na.strings = c("", "NA", "na", "Na", "NaN",
"Nan", ".","N/A","n/a", "N/a"),
blank.lines.skip = TRUE)
} else {
cat ("\n\n*** ERROR *** Something is rotten in the City of Gotham. The GWAS data is neither comma, tab, space, nor semicolon delimited. Double back, please.\n\n", file=stderr()) # print error messages to stder
}
} else if(filetype != "gzfile") {
cat("\n* The file appears not to be gezipped, checking delimiter now...")
TESTDELIMITER = readLines(opt$datagwas, n = 1)
cat("\n* Data header looks like this:\n")
print(TESTDELIMITER)
if(grepl(",", TESTDELIMITER) == TRUE){
cat("\n* Data is comma-seperated, loading...\n")
GWASDATA_RAW = fread(opt$datagwas,
header = TRUE, sep = ",",dec = ".",
na.strings = c("", "NA", "na", "Na","NaN",
"Nan", ".","N/A","n/a","N/a"),
blank.lines.skip = TRUE)
} else {
cat ("\n\n*** ERROR *** Something is rotten in the City of Gotham. The GWAS data is neither comma, tab, space, nor semicolon delimited. Double back, please.\n\n", file=stderr()) # print error messages to stder
}
} else {
cat ("\n\n*** ERROR *** Something is rotten in the City of Gotham. We can't determine the file type of the GWAS data. Double back, please.\n\n", file=stderr()) # print error messages to stder
}
closeAllConnections()
【问题讨论】:
标签: r