The very first thing that a new portalr user (conversant with R) is going to do after running
tbls <- load_rodent_data(portal_path)
is to run
tbls
and thus dump the entirety (up to R's print limits) of each data frame in tbls to the console.
Instead, if load_rodent_data() returned an object with an S3 class ("portal_data_list" for example), then portalr could provide a print.portal_data_list method that did something useful (list the names of the loaded data tables) and suggest how to access the individual data frames.
For example something like (but better, prettier, using crayon and clisymbols):
tbls2 <- tbls
class(tbls2) <- append(class(tbls2), "portal_data_list")
print.portal_data_list <- function(x, ...) {
x_name <- deparse(substitute(x))
tbls <- names(x)
writeLines("\nPortal data: a list with the following data frames:\n")
print(tbls, ...)
access_msg <- paste0("'", x_name, "$", tbls[1], "'")
writeLines(paste("\nAccess individual data sets with e.g.", access_msg))
invisible(x)
}
which gives:
> print(tbls2)
Portal data: a list with the following data frames:
[1] "rodent_data" "species_table" "trapping_table" "newmoons_table" "plots_table"
Access individual data sets with e.g. 'tbls2$rodent_data'
@gmyenni - I agree with @gavinsimpson that this would be a good change to improve this natural entry point into the package and the design change shouldn't cause any downstream issues.
The very first thing that a new portalr user (conversant with R) is going to do after running
is to run
and thus dump the entirety (up to R's print limits) of each data frame in
tbls
to the console.Instead, if
load_rodent_data()
returned an object with an S3 class ("portal_data_list"
for example), then portalr could provide aprint.portal_data_list
method that did something useful (list the names of the loaded data tables) and suggest how to access the individual data frames.For example something like (but better, prettier, using crayon and clisymbols):
which gives: