0

Here is the URL:

https://www.bls.gov/lau/laucnty15.txt

Unfortunately, I think the problem is that the table is tab-delimited but values are not delimited by quotes (""). So I don't know how I would strip out values using spaces without breaking apart the county name, for example.

I have tried:

webData <- data.frame(read.table(usrWebsiteURL,sep="\t",skip=5,header=F))

webData <- data.frame(readLines(usrWebsiteURL)),sep="\t",skip=5,header=F)

Either method creates a large, 1-column data.frame.

Why is the sep="\t" not working? Worse-case scenario, I can accept a split apart County Name and put it back together later, but I can't even achieve splitting apart the words in the table.

Pablo Boswell
  • 805
  • 3
  • 13
  • 30

1 Answers1

1

This code, using the readr (from CRAN) package worked for me:

    readr::read_table("https://www.bls.gov/lau/laucnty15.txt", skip = 6, col_names = FALSE)

You would probably want to add the column names after reading the file, but this can be done manually, eg., by using

    dat <- readr::read_table("https://www.bls.gov/lau/laucnty15.txt", skip = 6, col_names = FALSE)
    colnames(dat) <- c("LAUS Code", "State FIPS Code", "County FIPS Code", "County name", "Year", "Labor Force", "Employed", "Unemployed Level", "Unemployed Rate")
Fred Boehm
  • 656
  • 4
  • 11
  • I think that you can also just use the `col_names` argument of `readr::read_table()` to add the column names, rather than using a distinct line of code. – Fred Boehm Mar 30 '17 at 20:46