I have made a function that read input from file lists and appends it using rbind.
dat <- NA
file.names <- list.files(paste(in.path2,"CSV",sep =""))
for(f in file.names){
file <- paste(in.path2,"CSV/", f, sep = "")
tmp <- read.csv(file, stringsAsFactors = F, na.strings = c("", " "))
if (is.na(dat)) {
dat <- tmp
} else {
colnames(tmp) <- colnames(dat)
dat <- rbind(dat, tmp)
}
print(f)
}
I am getting this warning:
1: In if (is.na(dat)) { ... :
the condition has length > 1 and only the first element will be used.
How to correct this?