I have a curiously formatted text file with data that I'm trying to upload into R. The text file is structured in three huge lines of data (one for each variable). I'd like each line to be a column, and each entry to be an observation. The observations correspond to one another by order. As in, the 5th entry in 'epochNums' corresponds to the 5th entry in 'epochDates' and the 5th entry in 'epochDays'.
The problem is that in the first and third variables, each datapoint is separated by a space; in the second, datapoints are separated by quotations. I'm having trouble figuring out how to work around that as I upload the data. I have included three screenshots of the beginning of each variable as they appear in the text file.
And this link (https://www.dropbox.com/s/4ey94shqnk05jcm/Data?dl=0) should allow people to download the data.
Very grateful for any guidance!
CodePudding user response:
This will get the data read in, which is just the start of your problems, you will need to do some structuring to make this useful.
require(readtext)
data=readtext("data.txt")
data$text[1] #Returns the text in a giant string you need to parse
My way of handling this would be to use some kind of a text editor/simple IDE like Brackets or Notepad to go with find/replace and get it in the shape it needs to be to read as a tab or comma separated file, that would be the easiest way to work with it down the line, but you can read it in this way and figure out what to do with it from here.