Created
January 14, 2017 00:28
-
-
Save jrnold/d91844ae649b83eb66e0ea0d6f6c5ab5 to your computer and use it in GitHub Desktop.
Load country_csv.csv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library("readr") | |
| # see http://r4ds.had.co.nz/strings.html for functions to manipulate strings | |
| library("stringr") | |
| # Read individual lines into a character vector | |
| lines <- read_lines("data/county_data.csv") | |
| # delete the first and last character of each line | |
| lines <- str_sub(lines, 2, -2) | |
| # check that it worked by looking at the first line | |
| lines[1] | |
| # paste lines back together into a single string | |
| # \n is the newline | |
| lines <- str_c(lines, collapse = "\n") | |
| # now read_tsv should work | |
| read_tsv(lines) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment