0

I am trying to read in ASCII files in R.

The parent directory for the files can be found here. I would want to read in the county-level datasets for years 1970-1985. An example file is located here.

The exact format for the datafiles varies, for some it is: "ASCII, fixed-length fields with one record-delimiter (line feed)"; for others: "ASCII, fixed-length fields/records with two record-delimiters (carriage return and line feed); record length includes delimiters"

I tried to read in the data using read.table, import.asc and raster as discussed in a previous question. However, they all produce an error.

Thanks for help!

Community
  • 1
  • 1
Maarölli
  • 375
  • 1
  • 3
  • 13
  • Why do not you use `read.fwf`? or use `scan`. – user1436187 Jan 19 '16 at 13:08
  • I tried but these give out errors as well. Could you give a working example with one of the files on the website I linked to? – Maarölli Jan 19 '16 at 14:07
  • You don't have (or at least don't provide) enough information. These are fixed-width ASCII files. You need a "data dictionary" that specifies what fields are included in the file and what column positions each takes up. You can then write a `read.fwf()` statement that identifies the columns as variables. – Thomas Jan 19 '16 at 20:59

0 Answers0