I have a delimited text file that looks like this:
df1 <- data.frame(
ID = c(111, 121, 113, 211),
NAME = c('Jim', 'Jon', 'Jan', 'Jack'),
CAT = c('A', 'A', 'B','A'))
After reading into R with read.delim it looks like this:
df2 <- data.frame(
ID = c('Jim', 'Jon', 'Jan', 'Jack'),
NAME = c('A', 'A', 'B','A'),
CAT = c('', '', '',''))
This resulting df takes the first delimited column and adds it as the Row Header, so rows show as 111, 121, 113, 211. The columns are then all off by one and the last column is empty.
I can get it to work if I change the argument header = FALSE, all of the columns align correctly, the Row Headers take correct values, but there are no Column Headers anymore.
Code:
df1 <- read.delim(file = str.vec2, header = TRUE, sep = "|",
fill = TRUE)
Txt:
https://pastebin.com/SFb0w0Mm