Skip to content

Commit

Permalink
use example files
Browse files Browse the repository at this point in the history
  • Loading branch information
Yunuuuu committed Nov 1, 2023
1 parent 3b00ae7 commit 3a1c6fb
Show file tree
Hide file tree
Showing 18 changed files with 95 additions and 55 deletions.
2 changes: 1 addition & 1 deletion R/available.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#' @return A logical indicates FAERS can have data for the `years` and
#' `quarters` required?
#' @examples
#' faers_available(c(2011, 2023), c("q1", "q2"))
#' faers_available(c(2011, 2023), c("q1", "q2"))
#' @export
faers_available <- function(years, quarters, force = FALSE, internal = FALSE) {
assert_inclusive(quarters, faers_file_quarters)
Expand Down
13 changes: 9 additions & 4 deletions R/combine.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@
#' @param x A list of [FAERSxml] or [FAERSascii] objects.
#' @return A [FAERSxml] or [FAERSascii] object.
#' @examples
#' \donttest{
#' data1 <- faers(2004, "q1")
#' data2 <- faers(2004, "q2")
#' # the files included in the package are sampled
#' data1 <- faers_parse(
#' system.file("extdata", "aers_ascii_2004q1.zip", package = "faers"),
#' compress_dir = tempdir()
#' )
#' data2 <- faers_parse(
#' system.file("extdata", "faers_ascii_2017q2.zip", package = "faers"),
#' compress_dir = tempdir()
#' )
#' faers_combine(list(data1, data2))
#' }
#' @export
faers_combine <- function(x) {
assert_(x, is.list, "a list")
Expand Down
15 changes: 10 additions & 5 deletions R/dedup.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@
#' @param object A [FAERSascii] object.
#' @param ... Other arguments passed to specific methods.
#' @return A [FAERSascii] object.
#' @examples
#' @seealso [faers_standardize]
#' @examples
#' \dontrun{
#' data <- faers(2004, c("q1", "q2"))
#' # you should replace `meddra_path` with yours
#' data <- faers_standardize(data, meddra_path)
#' faers_dedup(data)
#' # you must change `dir`, as the files included in the package are sampled
#' data <- faers(c(2004, 2017), c("q1", "q2"),
#' dir = system.file("extdata", package = "faers")
#' )
#' # we must standardize firstly
#' # you should replace `meddra_path` with yours
#' data <- faers_standardize(data, meddra_path)
#' faers_dedup(data)
#' }
#' @export
#' @name faers_dedup
Expand Down
9 changes: 6 additions & 3 deletions R/download.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@
#' [new_handle][curl::new_handle].
#' @return An atomic character for the path of downloaded files.
#' @examples
#' \donttest{
#' faers_download(year = 2004, quarter = "q1", dir = tempdir())
#' }
#' # you must change `dir`, as the file included in the package is sampled
#' # in this way, the file will downloaded from FAERS
#' faers_download(
#' year = 2004, quarter = "q1",
#' dir = system.file("extdata", package = "faers")
#' )
#' @export
faers_download <- function(years, quarters, format = NULL, dir = getwd(), ...) {
format <- match.arg(format, faers_file_format)
Expand Down
7 changes: 3 additions & 4 deletions R/faers.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
#' @param handle_opts Extra handle options passed to each request
#' [new_handle][curl::new_handle].
#' @return A [FAERSxml] or [FAERSascii] object.
#' @examples
#' \donttest{
#' data <- faers(2004, "q1")
#' }
#' @examples
#' # you must change `dir`, as the file included in the package is sampled
#' data <- faers(2004, "q1", dir = system.file("extdata", package = "faers"))
#' @export
faers <- function(years, quarters, format = NULL, dir = getwd(), compress_dir = dir, handle_opts = list()) {
format <- match.arg(format, faers_file_format)
Expand Down
7 changes: 3 additions & 4 deletions R/merge.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
#'
#' @return A [data.table][data.table::data.table] object.
#' @examples
#' \donttest{
#' data <- faers(2004, "q1")
#' faers_merge(data, "indi")
#' # you must change `dir`, as the file included in the package is sampled
#' data <- faers(2004, "q1", dir = system.file("extdata", package = "faers"))
#' faers_merge(data, "indi") # only one field is just like faers_get()
#' faers_merge(data, c("demo", "indi"))
#' }
#' @export
#' @name faers_merge
methods::setGeneric("faers_merge", function(object, ...) {
Expand Down
5 changes: 2 additions & 3 deletions R/methods-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,15 @@
#' `faers_keep` to filter.
#' @export
#' @examples
#' \donttest{
#' data <- faers(2004, "q1")
#' # you must change `dir`, as the file included in the package is sampled
#' data <- faers(2004, "q1", dir = system.file("extdata", package = "faers"))
#' faers_get(data, "indi")
#' data[["indi"]]
#' faers_get(data, "demo")
#' data[["demo"]]
#' faers_mget(data, c("indi", "drug"))
#' faers_mget(data, c("indi", "demo"))
#' faers_primaryid(data)
#' }
#' @rdname FAERS-methods
methods::setGeneric("faers_get", function(object, ...) {
methods::makeStandardGeneric("faers_get")
Expand Down
6 changes: 6 additions & 0 deletions R/parse.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
#' @param compress_dir A string specifies the directory to extract files to. It
#' will be created if necessary.
#' @return A [FAERSxml] or [FAERSascii] object.
#' @examples
#' # the files included in the package are sampled
#' data <- faers_parse(
#' system.file("extdata", "aers_ascii_2004q1.zip", package = "faers"),
#' compress_dir = tempdir()
#' )
#' @export
faers_parse <- function(path, format = NULL, year = NULL, quarter = NULL, compress_dir = getwd()) {
assert_string(path, empty_ok = FALSE)
Expand Down
7 changes: 5 additions & 2 deletions R/standardize.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
#' <https://www.meddra.org/>
#' @examples
#' \dontrun{
#' data <- faers(2004, "q1")
#' #' # you must change `dir`, as the files included in the package are sampled
#' data <- faers(c(2004, 2017), c("q1", "q2"),
#' dir = system.file("extdata", package = "faers")
#' )
#' # you should replace `meddra_path` with yours
#' data <- faers_standardize(data, meddra_path)
#' data <- faers_standardize(data, meddra_path)
#' }
#' @export
#' @name faers_standardize
Expand Down
5 changes: 2 additions & 3 deletions man/FAERS-methods.Rd

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

5 changes: 2 additions & 3 deletions man/faers.Rd

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

2 changes: 1 addition & 1 deletion man/faers_available.Rd

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

13 changes: 9 additions & 4 deletions man/faers_combine.Rd

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

15 changes: 11 additions & 4 deletions man/faers_dedup.Rd

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

9 changes: 6 additions & 3 deletions man/faers_download.Rd

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

16 changes: 7 additions & 9 deletions man/faers_merge.Rd

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

7 changes: 7 additions & 0 deletions man/faers_parse.Rd

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

7 changes: 5 additions & 2 deletions man/faers_standardize.Rd

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

0 comments on commit 3a1c6fb

Please sign in to comment.