I uploaded a .txt file with "|,"
separators, so I used strsplit()
lob<-readLines("lob_lobbying.txt")
lob<-strsplit(lob, "|,", fixed=TRUE)
However, the output is a large list, with length 1213906. Each of these are a list of type characters, but some of them have length 16 and other 17.
I want to extract each of these rows and bind them into a data frame.
For example when i do
X <-rbind(lob[[1]],lob[[2]], lob[[3]])
df<-as.data.frame(X)
The X is exactly the type of output i want (because i then can do data.frame and it works perfect!) However, given the length of the list is 1213906 i need to automate this process.
But as soon as i try to do.call(rbind, lob)
it does not work. I get
"number of columns of result is not a multiple of vector length (arg 5)"
I think is because some of these character strings have length 16 and others length 17.
Is there a loop to extract each of this strings based if they have 16 or 17 characters and then bind them?