Learn R Programming

icd (version 2.2)

rtf_parse_lines: parse lines of RTF

Description

parse a character vector containing RTF strings

Usage

rtf_parse_lines(rtf_lines, verbose = FALSE, save_extras = FALSE, ...)

Arguments

rtf_lines

character vector containing RTF. Encoding?

verbose

single logical value, defaults to FALSE in most functions.

Value

named character vector, with names being the ICD-9 codes, and the contents being the descriptions from the RTF source. Elsewhere I do this the other way around, but the tests are now wired for this layout. 'Tidy' data would favour having an unnamed two-column data frame.

Details

... might include: perl = TRUE, useBytes = TRUE

Examples

Run this code
# NOT RUN {
f_info_rtf <- rtf_fetch_year("2011", offline = FALSE)
rtf_lines <- readLines(f_info_rtf$file_path, warn = FALSE, encoding = "ASCII")
microbenchmark::microbenchmark(
  res_both <- rtf_parse_lines(rtf_lines, perl = TRUE, useBytes = TRUE),
  res_none <- rtf_parse_lines(rtf_lines, perl = FALSE, useBytes = FALSE),
  res_bytes <- rtf_parse_lines(rtf_lines, perl = FALSE, useBytes = TRUE),
  res_perl <- rtf_parse_lines(rtf_lines, perl = TRUE, useBytes = FALSE),
  times = 5
)
stopifnot(identical(res_both, res_none))
# }

Run the code above in your browser using DataLab