-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgtfs_methods.R
49 lines (42 loc) · 1 KB
/
gtfs_methods.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#' Print a GTFS object
#'
#' Prints a GTFS object suppressing the \code{class} attribute.
#'
#' @param x A GTFS object.
#' @param ... Optional arguments ultimately passed to \code{format}.
#'
#' @return The GTFS object that was printed, invisibly.
#'
#' @examples
#' gtfs_path <- system.file("extdata/ggl_gtfs.zip", package = "gtfsio")
#' gtfs <- import_gtfs(gtfs_path)
#'
#' # subset 'gtfs' for a smaller output
#' gtfs <- gtfs[c("routes", "trips")]
#'
#' print(gtfs)
#'
#' @export
print.gtfs <- function(x, ...) {
print(unclass(x), ...)
return(invisible(x))
}
#' Print summary of a GTFS object
#'
#' @param object A GTFS object.
#' @param ... Ignored.
#'
#' @examples
#' gtfs_path <- system.file("extdata/ggl_gtfs.zip", package = "gtfsio")
#' gtfs <- import_gtfs(gtfs_path)
#'
#' summary(gtfs)
#'
#' @export
summary.gtfs <- function(object, ...) {
cat(
"A gtfs object with the following tables",
"and respective numbers of entries in each:\n"
)
print(vapply(object, nrow, numeric(1)))
}