Home > front end >  How can I convert this ABES ASCII/.dat file into a workable CSV file within R?
How can I convert this ABES ASCII/.dat file into a workable CSV file within R?

Time:05-18

The file is clunky, and I cannot find a way to import a workable version into R. I've tried read_csv(), read_delim(), readLines(), and readtable(), but nothing seems to be able to work. Some columns seem to be delimited by periods and some seem to be delimited by white space. More information on the publicly available data set can be found here

Let me know if you're able to help - thanks!

CodePudding user response:

A combination of the tidyverse and the SAS and SPSS scripts provided in the ABES documentation can be a timesaver here. For example, you can use the widths from the SPSS script with the readr::read_fwf() option fwf_cols(). For example, the first few columns to pass to fwf_cols() would look like this: Q1 = c(1, 17), Q2 = c(18, 18), Q3 = c(19, 19)). Once you have it working, you can check your frequencies against Appendix E in the ABES Data User's Guide.

  • Related