Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 7th, 2012  |  syntax: None  |  size: 0.81 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Is it possible to use R package data in testthat tests or run_examples()?
  2. / mypackage
  3.     / data
  4.         * foo.txt, bar.csv
  5.     / inst
  6.         / tests
  7.             * run-all.R, test_1.R
  8.     / man
  9.     / R
  10.        
  11. #' Foo data
  12.     #'
  13.     #' Sample foo data
  14.     #'
  15.     #' @name foo
  16.     #' @docType data
  17.     NULL
  18.     #' Bar data
  19.     #'
  20.     #' Sample bar data
  21.     #'
  22.     #' @name bar
  23.     #' @docType data
  24.     NULL
  25.        
  26. data(foo)
  27.     data(bar)
  28.     expect_that(foo$col[1], equals(bar$col[1]))
  29.        
  30. #' @examples
  31.     #' data(foo)
  32.     #' functionThatUsesFoo(foo)
  33.        
  34. #' @examples
  35.     #' dontrun{data(foo)}
  36.     #' dontrun{functionThatUsesFoo(foo)}
  37.        
  38. foo <- read.delim(pathToFoo, sep="t", fill = TRUE, comment.char="#")
  39.     bar <- read.delim(pathToBar, sep=";", fill = TRUE, comment.char="#"
  40.     expect_that(foo$col[1], equals(bar$col[1]))