R complete.cases不返回所需结果
我是这门语言的新手,并尝试使用代码。我正在尝试编写一个代码,读取文件夹中的CSV,并计算/打印每个文件的完整观察数(不带NAs的完整行)。我写了这段代码: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
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