diff --git a/R/allgensnp.R b/R/allgensnp.R index bdd8245..7a974b6 100644 --- a/R/allgensnp.R +++ b/R/allgensnp.R @@ -6,10 +6,9 @@ #' @param usersubset Get a subset of users, integer numbers, e.g. 1-8 (default: none) #' @param ... Curl options passed on to [crul::HttpClient] #' @return data.frame of genotypes for all users at a certain SNP -#' @examples \donttest{ +#' @examplesIf !rsnps:::is_rcmd_check() #' x <- allgensnp(snp = "rs7412") #' head(x) -#' } allgensnp <- function(snp = NA, usersubset = FALSE, ...) { ## add possibilty to get a subset of users diff --git a/R/allphenotypes.R b/R/allphenotypes.R index 2f16b38..1446b6f 100644 --- a/R/allphenotypes.R +++ b/R/allphenotypes.R @@ -12,7 +12,7 @@ #' number_of_users are replicated in the data.frame. Default: `FALSE` #' @param ... Curl options passed on to [crul::HttpClient] #' @return data.frame of openSNP phenotypes, variants and users per phenotype, or list if `df=FALSE` -#' @examples \donttest{ +#' @examplesIf !rsnps:::is_rcmd_check() #' # Get all data #' # Output a list, then call the characteristic of interest by 'id' or #' # 'characteristic' @@ -20,7 +20,6 @@ #' names(datalist) # get list of all characteristics you can call #' datalist[["ADHD"]] # get data.frame for 'ADHD' #' datalist[c("mouth size", "SAT Writing")] # get data.frame for 'ADHD' -#' } allphenotypes <- function(df = FALSE, ...) { tryCatch( { diff --git a/R/annotations.R b/R/annotations.R index 3322bfa..4544695 100644 --- a/R/annotations.R +++ b/R/annotations.R @@ -13,7 +13,7 @@ #' metadata for the response. #' @param ... Curl options passed on to [crul::HttpClient] #' @return data.frame of openSNP phenotypes from specified source -#' @examples \donttest{ +#' @examplesIf !rsnps:::is_rcmd_check() #' # Get all data #' ## get just the metadata #' annotations(snp = "rs7903146", output = "metadata") @@ -26,7 +26,7 @@ #' #' ## get all annotations #' annotations(snp = "rs7903146", output = "all") -#' } + annotations <- function(snp = NA, output = c("all", "plos", "mendeley", "snpedia", "metadata"), ...) { url <- paste0(osnp_base(), "snps/json/annotation/", snp, ".json") diff --git a/R/download_users.R b/R/download_users.R index 8974baf..6d0bff0 100644 --- a/R/download_users.R +++ b/R/download_users.R @@ -8,13 +8,13 @@ #' @param ... Curl options passed on to [crul::HttpClient] #' @return File downloaded to directory you specify (or default), nothing #' returned in R. -#' @examples \donttest{ +#' @examplesIf !rsnps:::is_rcmd_check() #' # Download a single user file, by id #' download_users(id = 14) #' #' # Download a single user file, by user name #' download_users(name = "kevinmcc") -#' } + download_users <- function(name = NULL, id = NULL, dir = "~/", ...) { if (is.null(name) && is.null(id)) { stop("You must specify one of name or id", call. = FALSE) @@ -61,12 +61,12 @@ get_write <- function(x, y, ...) { #' variables for the path to the file saved. Alternatively, you can supply #' the path. #' @return A data.frame with openSNP user files retrieved from local storage -#' @examples \donttest{ +#' @examplesIf !rsnps:::is_rcmd_check() #' #' download_users(name = "kevinmcc") #' dat <- read_users(name = "kevinmcc") #' head(dat) -#' } + read_users <- function(name = NULL, id = NULL, path = NULL, ...) { if (is.null(name) && is.null(id) && is.null(path)) { stop("You must specify one of name, id, or path", call. = FALSE) diff --git a/R/fetch_genotypes.R b/R/fetch_genotypes.R index 395c6f2..705386c 100644 --- a/R/fetch_genotypes.R +++ b/R/fetch_genotypes.R @@ -28,7 +28,7 @@ #' Internally, we use [download.file()] to download each file, then #' [read.table()] to read the file to a data.frame. #' -#' @examples \donttest{ +#' @examplesIf !rsnps:::is_rcmd_check() #' # get a data.frame of the users data #' mydata <- fetch_genotypes( #' url = data[[1]][1, "genotypes.download_url"], @@ -40,7 +40,6 @@ #' #' # Or read in data later separately #' read.table("~/myfile.txt", nrows = 10) -#' } fetch_genotypes <- function(url, rows = 100, filepath = NULL, quiet = TRUE, ...) { if (is.null(filepath)) filepath <- tempfile(fileext = ".txt") diff --git a/R/genotypes.R b/R/genotypes.R index 34d4574..c3de7cf 100644 --- a/R/genotypes.R +++ b/R/genotypes.R @@ -8,11 +8,10 @@ #' @param ... Curl options passed on to [crul::HttpClient]] #' @return List (or data.frame) of genotypes for specified user(s) at a #' certain SNP. -#' @examples \donttest{ +#' @examplesIf !rsnps:::is_rcmd_check() #' genotypes(snp = "rs9939609", userid = 1) #' genotypes("rs9939609", userid = "1,6,8", df = TRUE) #' genotypes("rs9939609", userid = "1-2", df = FALSE) -#' } genotypes <- function(snp = NA, userid = NA, df = FALSE, ...) { url2 <- paste0(paste0(osnp_base(), "snps/json/"), snp, "/", userid, ".json") diff --git a/R/ncbi_snp_api.R b/R/ncbi_snp_api.R index 8d379b9..34bca9d 100644 --- a/R/ncbi_snp_api.R +++ b/R/ncbi_snp_api.R @@ -211,7 +211,7 @@ get_gene_names <- function(primary_info) { #' If users want to set curl options when querying for the SNPs they can do so by using #' httr::set_config/httr::with_config #' -#' @examples \donttest{ +#' @examplesIf !rsnps:::is_rcmd_check() #' ## an example with both merged SNPs, non-SNV SNPs, regular SNPs, #' ## SNPs not found, microsatellite #' SNPs <- c("rs332", "rs420358", "rs1837253", "rs1209415715", "rs111068718") @@ -226,7 +226,6 @@ get_gene_names <- function(primary_info) { #' ncbi_snp_query(snps = "rs9970807") #' #' ncbi_snp_query("rs121909001") -#' } ncbi_snp_query <- function(snps) { ## NCBI moved to https but not using http v.2. The setting of the version diff --git a/R/phenotypes.R b/R/phenotypes.R index 8181882..03c4e88 100644 --- a/R/phenotypes.R +++ b/R/phenotypes.R @@ -7,14 +7,13 @@ #' @param ... Curl options passed on to [crul::HttpClient] #' @return List of phenotypes for specified user(s) from openSNP. #' -#' @examples \donttest{ +#' @examplesIf !rsnps:::is_rcmd_check() #' phenotypes(userid = 1) #' phenotypes(userid = "1,6,8", df = TRUE) #' phenotypes(userid = "1-8", df = TRUE) #' #' # pass on curl options #' phenotypes(1, verbose = TRUE) -#' } phenotypes <- function(userid = NA, df = FALSE, ...) { url2 <- paste0(paste0(osnp_base(), "phenotypes/json/"), userid, ".json") diff --git a/R/phenotypes_byid.R b/R/phenotypes_byid.R index bfef287..da0fc12 100644 --- a/R/phenotypes_byid.R +++ b/R/phenotypes_byid.R @@ -8,15 +8,13 @@ #' @param ... Curl options passed on to [crul::HttpClient] #' @return List of description of phenotype, list of known variants, or #' data.frame of variants for each user with that phenotype retrieved from openSNP. -#' -#' @examples \donttest{ +#' @examplesIf !rsnps:::is_rcmd_check() #' phenotypes_byid(phenotypeid = 12, return_ = "desc") #' phenotypes_byid(phenotypeid = 12, return_ = "knownvars") #' phenotypes_byid(phenotypeid = 12, return_ = "users") #' #' # pass on curl options #' phenotypes_byid(phenotypeid = 12, return_ = "desc", verbose = TRUE) -#' } phenotypes_byid <- function(phenotypeid = NA, return_ = c("description", "knownvars", "users"), ...) { url2 <- paste0( diff --git a/R/users.R b/R/users.R index 2664b91..4dbe8b1 100644 --- a/R/users.R +++ b/R/users.R @@ -5,12 +5,11 @@ #' @param df Return data.frame (`TRUE`) or not (`FALSE`). Default: `FALSE` #' @param ... Curl options passed on to [crul::HttpClient] #' @return List of openSNP users, their ID numbers, and genome data if available. -#' @examples \donttest{ +#' @examplesIf !rsnps:::is_rcmd_check() #' # get a data.frame of the users data #' data <- users(df = TRUE) #' data[[1]] # users with links to genome data #' data[[2]] # users without links to genome data -#' } users <- function(df = FALSE, ...) { diff --git a/R/utils.R b/R/utils.R index 001c504..dbae421 100644 --- a/R/utils.R +++ b/R/utils.R @@ -114,3 +114,11 @@ release_bullets <- function() { "Bump dev version" ) } + +is_rcmd_check <- function () { + if (identical(Sys.getenv("NOT_CRAN"), "true")) { + FALSE + } else { + Sys.getenv("_R_CHECK_PACKAGE_NAME_", "") != "" + } +} diff --git a/man/allgensnp.Rd b/man/allgensnp.Rd index 00a0ab6..63ed0bd 100644 --- a/man/allgensnp.Rd +++ b/man/allgensnp.Rd @@ -20,10 +20,10 @@ data.frame of genotypes for all users at a certain SNP Get openSNP genotype data for all users at a particular snp. } \examples{ -\donttest{ +\dontshow{if (!rsnps:::is_rcmd_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} x <- allgensnp(snp = "rs7412") head(x) -} +\dontshow{\}) # examplesIf} } \seealso{ Other opensnp-fxns: diff --git a/man/allphenotypes.Rd b/man/allphenotypes.Rd index d1da155..e87041e 100644 --- a/man/allphenotypes.Rd +++ b/man/allphenotypes.Rd @@ -23,7 +23,7 @@ the characteristic by id (parameter = "id") or name (parameter = "characteristic"). } \examples{ -\donttest{ +\dontshow{if (!rsnps:::is_rcmd_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} # Get all data # Output a list, then call the characteristic of interest by 'id' or # 'characteristic' @@ -31,7 +31,7 @@ datalist <- allphenotypes() names(datalist) # get list of all characteristics you can call datalist[["ADHD"]] # get data.frame for 'ADHD' datalist[c("mouth size", "SAT Writing")] # get data.frame for 'ADHD' -} +\dontshow{\}) # examplesIf} } \seealso{ Other opensnp-fxns: diff --git a/man/annotations.Rd b/man/annotations.Rd index 0a82d3d..7c5057d 100644 --- a/man/annotations.Rd +++ b/man/annotations.Rd @@ -29,7 +29,7 @@ the characteristic by id (parameter = "id") or name (parameter = "characteristic"). } \examples{ -\donttest{ +\dontshow{if (!rsnps:::is_rcmd_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} # Get all data ## get just the metadata annotations(snp = "rs7903146", output = "metadata") @@ -42,7 +42,7 @@ annotations(snp = "rs7903146", output = "snpedia") ## get all annotations annotations(snp = "rs7903146", output = "all") -} +\dontshow{\}) # examplesIf} } \seealso{ Other opensnp-fxns: diff --git a/man/download_users.Rd b/man/download_users.Rd index 17a9b90..6495fec 100644 --- a/man/download_users.Rd +++ b/man/download_users.Rd @@ -23,13 +23,13 @@ returned in R. Download openSNP user files. } \examples{ -\donttest{ +\dontshow{if (!rsnps:::is_rcmd_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} # Download a single user file, by id download_users(id = 14) # Download a single user file, by user name download_users(name = "kevinmcc") -} +\dontshow{\}) # examplesIf} } \seealso{ Other opensnp-fxns: diff --git a/man/fetch_genotypes.Rd b/man/fetch_genotypes.Rd index f04d21d..7118c4e 100644 --- a/man/fetch_genotypes.Rd +++ b/man/fetch_genotypes.Rd @@ -45,7 +45,7 @@ Internally, we use \code{\link[=download.file]{download.file()}} to download eac \code{\link[=read.table]{read.table()}} to read the file to a data.frame. } \examples{ -\donttest{ +\dontshow{if (!rsnps:::is_rcmd_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} # get a data.frame of the users data mydata <- fetch_genotypes( url = data[[1]][1, "genotypes.download_url"], @@ -57,7 +57,7 @@ mydata # Or read in data later separately read.table("~/myfile.txt", nrows = 10) -} +\dontshow{\}) # examplesIf} } \seealso{ Other opensnp-fxns: diff --git a/man/genotypes.Rd b/man/genotypes.Rd index d376eba..dda552d 100644 --- a/man/genotypes.Rd +++ b/man/genotypes.Rd @@ -23,11 +23,11 @@ certain SNP. Get openSNP genotype data for one or multiple users. } \examples{ -\donttest{ +\dontshow{if (!rsnps:::is_rcmd_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} genotypes(snp = "rs9939609", userid = 1) genotypes("rs9939609", userid = "1,6,8", df = TRUE) genotypes("rs9939609", userid = "1-2", df = FALSE) -} +\dontshow{\}) # examplesIf} } \seealso{ Other opensnp-fxns: diff --git a/man/ncbi_snp_query.Rd b/man/ncbi_snp_query.Rd index 62e2353..b710b19 100644 --- a/man/ncbi_snp_query.Rd +++ b/man/ncbi_snp_query.Rd @@ -62,7 +62,7 @@ If users want to set curl options when querying for the SNPs they can do so by u httr::set_config/httr::with_config } \examples{ -\donttest{ +\dontshow{if (!rsnps:::is_rcmd_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} ## an example with both merged SNPs, non-SNV SNPs, regular SNPs, ## SNPs not found, microsatellite SNPs <- c("rs332", "rs420358", "rs1837253", "rs1209415715", "rs111068718") @@ -77,7 +77,7 @@ ncbi_snp_query("rs111068718") ncbi_snp_query(snps = "rs9970807") ncbi_snp_query("rs121909001") -} +\dontshow{\}) # examplesIf} } \references{ \url{https://www.ncbi.nlm.nih.gov/projects/SNP/} diff --git a/man/phenotypes.Rd b/man/phenotypes.Rd index d66b58b..b1734ba 100644 --- a/man/phenotypes.Rd +++ b/man/phenotypes.Rd @@ -20,14 +20,14 @@ List of phenotypes for specified user(s) from openSNP. Get openSNP phenotype data for one or multiple users. } \examples{ -\donttest{ +\dontshow{if (!rsnps:::is_rcmd_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} phenotypes(userid = 1) phenotypes(userid = "1,6,8", df = TRUE) phenotypes(userid = "1-8", df = TRUE) # pass on curl options phenotypes(1, verbose = TRUE) -} +\dontshow{\}) # examplesIf} } \seealso{ Other opensnp-fxns: diff --git a/man/phenotypes_byid.Rd b/man/phenotypes_byid.Rd index 817abb6..8952607 100644 --- a/man/phenotypes_byid.Rd +++ b/man/phenotypes_byid.Rd @@ -27,14 +27,14 @@ Get all openSNP known variations and all users sharing that phenotype for one phenotype(-ID). } \examples{ -\donttest{ +\dontshow{if (!rsnps:::is_rcmd_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} phenotypes_byid(phenotypeid = 12, return_ = "desc") phenotypes_byid(phenotypeid = 12, return_ = "knownvars") phenotypes_byid(phenotypeid = 12, return_ = "users") # pass on curl options phenotypes_byid(phenotypeid = 12, return_ = "desc", verbose = TRUE) -} +\dontshow{\}) # examplesIf} } \seealso{ Other opensnp-fxns: diff --git a/man/read_users.Rd b/man/read_users.Rd index 829f207..f6efa85 100644 --- a/man/read_users.Rd +++ b/man/read_users.Rd @@ -30,10 +30,10 @@ variables for the path to the file saved. Alternatively, you can supply the path. } \examples{ -\donttest{ +\dontshow{if (!rsnps:::is_rcmd_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} download_users(name = "kevinmcc") dat <- read_users(name = "kevinmcc") head(dat) -} +\dontshow{\}) # examplesIf} } diff --git a/man/users.Rd b/man/users.Rd index b9dd29c..203bef8 100644 --- a/man/users.Rd +++ b/man/users.Rd @@ -18,12 +18,12 @@ List of openSNP users, their ID numbers, and genome data if available. Get openSNP users. } \examples{ -\donttest{ +\dontshow{if (!rsnps:::is_rcmd_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} # get a data.frame of the users data data <- users(df = TRUE) data[[1]] # users with links to genome data data[[2]] # users without links to genome data -} +\dontshow{\}) # examplesIf} } \seealso{ Other opensnp-fxns: