Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R complete.cases不返回所需结果_R - Fatal编程技术网

R complete.cases不返回所需结果

R complete.cases不返回所需结果,r,R,我是这门语言的新手,并尝试使用代码。我正在尝试编写一个代码,读取文件夹中的CSV,并计算/打印每个文件的完整观察数(不带NAs的完整行)。我写了这段代码: complete <- function(directory, id = 1:332) { positivematch <- NULL setwd(file.path("c:/Rpro/",directory)) for (i in id) { filer <- paste(sprintf("%03d", as

我是这门语言的新手,并尝试使用代码。我正在尝试编写一个代码,读取文件夹中的CSV,并计算/打印每个文件的完整观察数(不带NAs的完整行)。我写了这段代码:

complete <- function(directory, id = 1:332) {

positivematch <- NULL

setwd(file.path("c:/Rpro/",directory))

for (i in id) {
    filer <- paste(sprintf("%03d", as.numeric(i)), ".csv", sep="")
    filed <- read.csv(filer)
    calc <- complete.cases(filed)
    positivematch[i] <- sum(calc == TRUE)
    }


out <- data.frame(id = id, nobs = positivematch)
return(out)
}
而不是

  id nobs
3  3  243

您能帮忙吗。

您是否仅使用
id=3
运行它?当您运行
positivematch[i]是时。执行已完成(“specdata”,3)您是否仅使用
id=3
运行它?当您运行
positivematch[i]是时。执行完成(“specdata”,3)
  id nobs
3  3  243