Skip to content

Commit

Permalink
Add new whitespace-delimited example file and update examples for `re…
Browse files Browse the repository at this point in the history
…ad_table()` and `melt_*()` (#1354)

* add example whitespace delimited file

* edit read_table example file

* update file paths for new examples

* make cleaner example

* changed cat() to writeLines()

* remove massey-rating example

* update roxygen docs

* change to read_lines()

* update melt() examples

* revert massey file

* update roxygen docs
  • Loading branch information
sbearrows authored Jan 25, 2022
1 parent b33567d commit 90736aa
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 39 deletions.
15 changes: 6 additions & 9 deletions R/melt_table.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,13 @@
#' @inheritParams read_table
#' @export
#' @examples
#' # One corner from http://www.masseyratings.com/cf/compare.htm
#' massey <- readr_example("massey-rating.txt")
#' cat(read_file(massey))
#' melt_table(massey)
#' fwf <- readr_example("fwf-sample.txt")
#' writeLines(read_lines(fwf))
#' melt_table(fwf)
#'
#' # Sample of 1978 fuel economy data from
#' # http://www.fueleconomy.gov/feg/epadata/78data.zip
#' epa <- readr_example("epa78.txt")
#' cat(read_file(epa))
#' melt_table(epa)
#' ws <- readr_example("whitespace-sample.txt")
#' writeLines(read_lines(ws))
#' melt_table2(ws)
melt_table <- function(file, locale = default_locale(), na = "NA", skip = 0,
n_max = Inf, guess_max = min(n_max, 1000),
progress = show_progress(), comment = "",
Expand Down
13 changes: 3 additions & 10 deletions R/read_table.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,9 @@
#' @inheritParams read_delim
#' @export
#' @examples
#' # One corner from http://www.masseyratings.com/cf/compare.htm
#' massey <- readr_example("massey-rating.txt")
#' cat(read_file(massey))
#' read_table(massey)
#'
#' # Sample of 1978 fuel economy data from
#' # http://www.fueleconomy.gov/feg/epadata/78data.zip
#' epa <- readr_example("epa78.txt")
#' cat(read_file(epa))
#' read_table(epa, col_names = FALSE)
#' ws <- readr_example("whitespace-sample.txt")
#' writeLines(read_lines(ws))
#' read_table(ws)

#' @rdname read_table
#' @export
Expand Down
4 changes: 4 additions & 0 deletions inst/extdata/whitespace-sample.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
first last state phone
John Smith WA 418-Y11-4111
Mary Hartford CA 319-Z19-4341
Evan Nolan IL 219-532-c301
17 changes: 7 additions & 10 deletions man/melt_table.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 3 additions & 10 deletions man/read_table.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 90736aa

Please sign in to comment.