scanData.go <- function(inFileName, colName, colType, headerFg = FALSE, sep = ",", ...){ if(length(colName)>length(colType[!colType == "NULL"])) stop("more column names than columns") skip <- 0 if(headerFg){ skip <- 1 } tmp1 <- vector("list",length(colType)) notNull <- which(!colType == "NULL", arr.ind = T) for(i in 1:length(notNull)){ tmp <- colType[notNull[i]] switch(match(tmp,c("char","num","logical")), tmp1[[notNull[i]]] <- "character", tmp1[[notNull[i]]] <- double(0), tmp1[[notNull[i]]] <- logical) } out <- scan(inFileName, what = tmp1, skip = skip, sep = sep) out <- out[!(colType == "NULL")] if(length(colName) < length(out)){ colName <- c(colName, paste("V", 1:(length(out)-length(colName)), sep = "")) warning("header and 'col.names' are of different lengths") } names(out) <- colName return(out) }