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

image

files <- sample(list.files("/full/path/", full.names=T, pattern = "*[1-9]"),2)
library(doParallel)
library(plyr)
    registerDoParallel(cores = 4)
    library(foreach)
    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 <- as.data.frame(lines = readLines("file path"))

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