From 820398ba4a627f551a29a166a93c1db543f33467 Mon Sep 17 00:00:00 2001 From: Flavio Poletti Date: Fri, 23 Jun 2023 13:32:56 +0200 Subject: [PATCH] add \dontrun{} to examples to pass Debian CRAN check --- R/dates.R | 7 ------- R/geo.R | 8 +++++--- R/time.R | 2 ++ R/validate_gtfs.R | 20 +++++++++++++++++++- man/interpolate_stop_times.Rd | 2 ++ man/set_dates_services.Rd | 8 -------- man/stop_distances.Rd | 3 ++- man/stop_group_distances.Rd | 3 ++- man/validate_gtfs.Rd | 20 +++++++++++++++++++- 9 files changed, 51 insertions(+), 22 deletions(-) diff --git a/R/dates.R b/R/dates.R index 814cff51..e6b0cace 100644 --- a/R/dates.R +++ b/R/dates.R @@ -42,13 +42,6 @@ convert_dates <- function(gtfs_obj, parse_function = parse_gtfsio_date) { #' #' @keywords internal #' @importFrom stats reshape -#' @examples -#' library(dplyr) -#' local_gtfs_path <- system.file("extdata", "google_transit_nyc_subway.zip", package = "tidytransit") -#' nyc <- read_gtfs(local_gtfs_path) -#' nyc_services_by_date <- nyc$.$dates_services -#' # count the number of services running on each date -#' nyc_services_by_date %>% group_by(date) %>% count() set_dates_services <- function(gtfs_obj) { has_calendar = feed_contains(gtfs_obj, "calendar") && nrow(gtfs_obj[["calendar"]]) > 0 has_calendar_dates = feed_contains(gtfs_obj, "calendar_dates") && nrow(gtfs_obj[["calendar_dates"]]) > 0 diff --git a/R/geo.R b/R/geo.R index ac9bfddd..da1719e9 100644 --- a/R/geo.R +++ b/R/geo.R @@ -10,6 +10,7 @@ #' among all stops for large feeds should be avoided #' #' @examples +#' \dontrun{ #' library(dplyr) #' #' nyc_path <- system.file("extdata", "google_transit_nyc_subway.zip", package = "tidytransit") @@ -34,7 +35,7 @@ #' #> 9 423S 232S 91.5 #' #> 10 232 423 91.5 #' #> # … with 26 more rows -#' +#' } #' @export stop_distances = function(gtfs_stops) { stopifnot(nrow(gtfs_stops) > 1) @@ -98,7 +99,8 @@ prep_dist_mtrx = function(dist_list) { #' number of stop ids within that group (n_stop_ids) and distance summary values #' (dist_mean, dist_median and dist_max). #' -#' @examples +#' @examples +#' \dontrun{ #' library(dplyr) #' #' nyc_path <- system.file("extdata", "google_transit_nyc_subway.zip", package = "tidytransit") @@ -119,7 +121,7 @@ prep_dist_mtrx = function(dist_list) { #' #> 9 7 Av 9 5479. 5479. 10753. #' #> 10 111 St 9 3877. 3877. 7753. #' #> # … with 370 more rows -#' +#' } #' @export stop_group_distances = function(gtfs_stops, by = "stop_name") { distances <- n_stop_ids <- dist_mean <- dist_median <- dist_max <- NULL diff --git a/R/time.R b/R/time.R index 2b3ad2e1..b8f97dee 100644 --- a/R/time.R +++ b/R/time.R @@ -106,6 +106,7 @@ replace_NA_times = function(stop_times) { #' are interpolated equally between stops. #' @return tidygtfs or stop_times with interpolated arrival and departure times #' @examples +#' \dontrun{ #' data(gtfs_duke) #' print(gtfs_duke$stop_times[1:5, 1:5]) #' @@ -114,6 +115,7 @@ replace_NA_times = function(stop_times) { #' #' gtfs_duke_3 = interpolate_stop_times(gtfs_duke, FALSE) #' print(gtfs_duke_3$stop_times[1:5, 1:5]) +#' } #' @export interpolate_stop_times = function(x, use_shape_dist = TRUE) { ....event_time <- ....shape_dist_traveled <- NULL diff --git a/R/validate_gtfs.R b/R/validate_gtfs.R index e8469536..23cd5690 100644 --- a/R/validate_gtfs.R +++ b/R/validate_gtfs.R @@ -42,6 +42,24 @@ #' } #' #' @examples +#' validate_gtfs(gtfs_duke) +#' #> # A tibble: 233 × 8 +#' #> file file_spec file_provided_status field field_spec field_provided_status +#' #> +#' #> 1 agency req TRUE agenc… opt TRUE +#' #> 2 agency req TRUE agenc… req TRUE +#' #> 3 agency req TRUE agenc… req TRUE +#' #> 4 agency req TRUE agenc… req TRUE +#' #> 5 agency req TRUE agenc… opt TRUE +#' #> 6 agency req TRUE agenc… opt TRUE +#' #> 7 agency req TRUE agenc… opt TRUE +#' #> 8 agency req TRUE agenc… opt FALSE +#' #> 9 stops req TRUE stop_… req TRUE +#' #> 10 stops req TRUE stop_… opt TRUE +#' #> # 223 more rows +#' #> # 2 more variables: validation_status , validation_details +#' +#' \dontrun{ #' local_gtfs_path <- system.file("extdata", "google_transit_nyc_subway.zip", package = "tidytransit") #' gtfs <- read_gtfs(local_gtfs_path) #' attr(gtfs, "validation_result") @@ -52,7 +70,7 @@ #' # should raise a warning #' gtfs$stop_times <- NULL #' validation_result <- validate_gtfs(gtfs) -#' +#' } #' @export validate_gtfs <- function(gtfs_obj, files = NULL, warnings = TRUE) { diff --git a/man/interpolate_stop_times.Rd b/man/interpolate_stop_times.Rd index b00ec344..99121842 100644 --- a/man/interpolate_stop_times.Rd +++ b/man/interpolate_stop_times.Rd @@ -22,6 +22,7 @@ Interpolate missing stop_times linearly Uses shape_dist_traveled if available } \examples{ +\dontrun{ data(gtfs_duke) print(gtfs_duke$stop_times[1:5, 1:5]) @@ -31,3 +32,4 @@ print(gtfs_duke_2$stop_times[1:5, 1:5]) gtfs_duke_3 = interpolate_stop_times(gtfs_duke, FALSE) print(gtfs_duke_3$stop_times[1:5, 1:5]) } +} diff --git a/man/set_dates_services.Rd b/man/set_dates_services.Rd index 5fd5320a..961ecc80 100644 --- a/man/set_dates_services.Rd +++ b/man/set_dates_services.Rd @@ -16,12 +16,4 @@ a date_service data frame Use it to summarise service. For example, get a count of the number of services for a date. See example. } -\examples{ -library(dplyr) -local_gtfs_path <- system.file("extdata", "google_transit_nyc_subway.zip", package = "tidytransit") -nyc <- read_gtfs(local_gtfs_path) -nyc_services_by_date <- nyc$.$dates_services -# count the number of services running on each date -nyc_services_by_date \%>\% group_by(date) \%>\% count() -} \keyword{internal} diff --git a/man/stop_distances.Rd b/man/stop_distances.Rd index 8c434ac9..2993b7e0 100644 --- a/man/stop_distances.Rd +++ b/man/stop_distances.Rd @@ -22,6 +22,7 @@ The resulting data.frame has nrow(gtfs_stops)^2 rows, distances calculations among all stops for large feeds should be avoided } \examples{ +\dontrun{ library(dplyr) nyc_path <- system.file("extdata", "google_transit_nyc_subway.zip", package = "tidytransit") @@ -46,5 +47,5 @@ nyc$stops \%>\% #> 9 423S 232S 91.5 #> 10 232 423 91.5 #> # … with 26 more rows - +} } diff --git a/man/stop_group_distances.Rd b/man/stop_group_distances.Rd index 629129c8..c70b7023 100644 --- a/man/stop_group_distances.Rd +++ b/man/stop_group_distances.Rd @@ -21,6 +21,7 @@ number of stop ids within that group (n_stop_ids) and distance summary values By default calculates distances among stop_ids with the same stop_name. } \examples{ +\dontrun{ library(dplyr) nyc_path <- system.file("extdata", "google_transit_nyc_subway.zip", package = "tidytransit") @@ -41,5 +42,5 @@ stop_group_distances(nyc$stops) #> 9 7 Av 9 5479. 5479. 10753. #> 10 111 St 9 3877. 3877. 7753. #> # … with 370 more rows - +} } diff --git a/man/validate_gtfs.Rd b/man/validate_gtfs.Rd index 35d6ca88..2d7cb68e 100644 --- a/man/validate_gtfs.Rd +++ b/man/validate_gtfs.Rd @@ -56,6 +56,24 @@ present, however, it becomes optional and \code{calendar_dates.txt} } \examples{ +validate_gtfs(gtfs_duke) +#> # A tibble: 233 × 8 +#> file file_spec file_provided_status field field_spec field_provided_status +#> +#> 1 agency req TRUE agenc… opt TRUE +#> 2 agency req TRUE agenc… req TRUE +#> 3 agency req TRUE agenc… req TRUE +#> 4 agency req TRUE agenc… req TRUE +#> 5 agency req TRUE agenc… opt TRUE +#> 6 agency req TRUE agenc… opt TRUE +#> 7 agency req TRUE agenc… opt TRUE +#> 8 agency req TRUE agenc… opt FALSE +#> 9 stops req TRUE stop_… req TRUE +#> 10 stops req TRUE stop_… opt TRUE +#> # 223 more rows +#> # 2 more variables: validation_status , validation_details + +\dontrun{ local_gtfs_path <- system.file("extdata", "google_transit_nyc_subway.zip", package = "tidytransit") gtfs <- read_gtfs(local_gtfs_path) attr(gtfs, "validation_result") @@ -66,5 +84,5 @@ validation_result <- validate_gtfs(gtfs) # should raise a warning gtfs$stop_times <- NULL validation_result <- validate_gtfs(gtfs) - +} }