diff --git a/R/available.R b/R/available.R index 2ad9055..7383b12 100644 --- a/R/available.R +++ b/R/available.R @@ -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) diff --git a/R/combine.R b/R/combine.R index a094cbe..3c4ee82 100644 --- a/R/combine.R +++ b/R/combine.R @@ -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") diff --git a/R/dedup.R b/R/dedup.R index c23fab3..46165d1 100644 --- a/R/dedup.R +++ b/R/dedup.R @@ -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 diff --git a/R/download.R b/R/download.R index fe5e435..4c4ab9e 100644 --- a/R/download.R +++ b/R/download.R @@ -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) diff --git a/R/faers.R b/R/faers.R index 1c47884..7dced57 100644 --- a/R/faers.R +++ b/R/faers.R @@ -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) diff --git a/R/merge.R b/R/merge.R index 03a4173..62065fc 100644 --- a/R/merge.R +++ b/R/merge.R @@ -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, ...) { diff --git a/R/methods-utils.R b/R/methods-utils.R index daebe8f..08fa564 100644 --- a/R/methods-utils.R +++ b/R/methods-utils.R @@ -25,8 +25,8 @@ #' `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") @@ -34,7 +34,6 @@ #' 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") diff --git a/R/parse.R b/R/parse.R index 933bb37..ec08017 100644 --- a/R/parse.R +++ b/R/parse.R @@ -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) diff --git a/R/standardize.R b/R/standardize.R index ca6d068..0ed97c1 100644 --- a/R/standardize.R +++ b/R/standardize.R @@ -6,9 +6,12 @@ #' #' @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 diff --git a/man/FAERS-methods.Rd b/man/FAERS-methods.Rd index 4405f9e..1648238 100644 --- a/man/FAERS-methods.Rd +++ b/man/FAERS-methods.Rd @@ -102,8 +102,8 @@ better to run \link[=FAERS]{faers}. } } \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") @@ -112,4 +112,3 @@ better to run \link[=FAERS]{faers}. faers_mget(data, c("indi", "demo")) faers_primaryid(data) } -} diff --git a/man/faers.Rd b/man/faers.Rd index eabfffe..3fe75d0 100644 --- a/man/faers.Rd +++ b/man/faers.Rd @@ -38,7 +38,6 @@ A \link{FAERSxml} or \link{FAERSascii} object. Download and parse FAERS Quarterly Data files } \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")) } diff --git a/man/faers_available.Rd b/man/faers_available.Rd index 5d88a38..3000526 100644 --- a/man/faers_available.Rd +++ b/man/faers_available.Rd @@ -28,5 +28,5 @@ This function check if data for the years and quarters selected are available at FAERS to be downloaded. } \examples{ -faers_available(c(2011, 2023), c("q1", "q2")) + faers_available(c(2011, 2023), c("q1", "q2")) } diff --git a/man/faers_combine.Rd b/man/faers_combine.Rd index 466710e..f7684cf 100644 --- a/man/faers_combine.Rd +++ b/man/faers_combine.Rd @@ -17,9 +17,14 @@ Packed all \link{FAERSascii} or \link{FAERSxml} objects into a single \link{FAER \link{FAERSxml} 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)) } -} diff --git a/man/faers_dedup.Rd b/man/faers_dedup.Rd index f0d3514..4022863 100644 --- a/man/faers_dedup.Rd +++ b/man/faers_dedup.Rd @@ -31,9 +31,16 @@ Tidy up FAERS Quarterly Data with duplicate records removed } \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) } } +\seealso{ +\link{faers_standardize} +} diff --git a/man/faers_download.Rd b/man/faers_download.Rd index 7984757..e695a44 100644 --- a/man/faers_download.Rd +++ b/man/faers_download.Rd @@ -28,7 +28,10 @@ An atomic character for the path of downloaded files. This function downloads the FAERS data for selected years and quarters. } \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") +) } diff --git a/man/faers_merge.Rd b/man/faers_merge.Rd index 4679d3b..455d97e 100644 --- a/man/faers_merge.Rd +++ b/man/faers_merge.Rd @@ -26,11 +26,10 @@ faers_merge(object, ...) \item{all}{logical; \code{all = TRUE} is shorthand to save setting both \code{all.x = TRUE} and \code{all.y = TRUE}.} -\item{all.x}{logical; if \code{TRUE}, then extra rows will be added to the -output, one for each row in \code{x} that has no matching row in \code{y}. -These rows will have 'NA's in those columns that are usually filled with values -from \code{y}. The default is \code{FALSE}, so that only rows with data from both -\code{x} and \code{y} are included in the output.} +\item{all.x}{logical; if \code{TRUE}, rows from \code{x} which have no matching row +in \code{y} are included. These rows will have 'NA's in the columns that are usually +filled with values from \code{y}. The default is \code{FALSE} so that only rows with +data from both \code{x} and \code{y} are included in the output.} \item{all.y}{logical; analogous to \code{all.x} above.} } @@ -54,9 +53,8 @@ You'd better only merge necessary data, otherwise a lot of memory will be consumed to merge all fields data. } \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")) } -} diff --git a/man/faers_parse.Rd b/man/faers_parse.Rd index 6e2abc2..80e7cf8 100644 --- a/man/faers_parse.Rd +++ b/man/faers_parse.Rd @@ -36,3 +36,10 @@ A \link{FAERSxml} or \link{FAERSascii} object. \description{ Parse FAERS Quarterly Data } +\examples{ +# the files included in the package are sampled +data <- faers_parse( + system.file("extdata", "aers_ascii_2004q1.zip", package = "faers"), + compress_dir = tempdir() +) +} diff --git a/man/faers_standardize.Rd b/man/faers_standardize.Rd index 45baaf5..9d354bd 100644 --- a/man/faers_standardize.Rd +++ b/man/faers_standardize.Rd @@ -24,9 +24,12 @@ Standardize FAERS Quarterly Data for Preferred Term and drug names } \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) } } \seealso{