Trying to left shift columns in a dataframe base on the presense of whitespace/NA/Null


files <- sample(list.files("/full/path/", full.names=T, pattern = "*[1-9]"),2)
    registerDoParallel(cores = 4)
    data2 <- foreach(i = files, .combine = rbind, stringsAsFactors = default.stringsAsFactors(), factor.exclude = NA)  %dopar%  read.table(i, sep = " ", fill = TRUE, **skipNul = TRUE**, header = FALSE)

I'm trying to invoke doparallel around read.table, primarily because I want the skipNul functionality to shift the columns in data to the left based on the presence of whitespace. the source files are space delimited already, but when it comes to the date stamp in the file with single digit dates, its treating that as nul space and shifting the data to the right and offsetting the values of my table. If I invoke a single file using read.table, this solves the issue but I'm losing something in doing this through doparallel. I'm presuming this is because of how rbind is working to concat the files. Any help on a better way to do this would be very much appreciated!

I'd probably read the file as text lines using readLines, and then use stringr to split the columns manually.

data <- = readLines("file path"))

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.