-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from karlropkins/main
rsp_match_profile update - now in main version
- Loading branch information
Showing
34 changed files
with
1,350 additions
and
573 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,20 @@ | ||
Package: respeciate | ||
Title: Speciation profiles for gases and aerosols | ||
Version: 0.3.2 | ||
Date: 2024-07-09 | ||
Description: Access to the air pollutant emission profiles in US EPA SPECIATE (v5.2) and | ||
EU JRC SPECIEUROPE archives. More details in Simon et al (2010) | ||
doi:10.5094/APR.2010.026 and Pernigotti et al (2016) | ||
doi:10.1016/j.apr.2015.10.007, respectively. | ||
Version: 0.3.5 | ||
Date: 2025-02-19 | ||
Description: Access to the air pollutant emission profiles in US EPA SPECIATE (v5.2) and EU JRC | ||
SPECIEUROPE archives. More details in Simon et al (2010) doi:10.5094/APR.2010.026 and | ||
Pernigotti et al (2016) doi:10.1016/j.apr.2015.10.007, respectively. | ||
Type: Package | ||
Authors@R: c( person(given = "Sergio", family = "Ibarra-Espinosa", role = c("aut", | ||
"cre"), email = "sergio.ibarra@usp.br", comment = c(ORCID = | ||
"0000-0002-3162-1905")), person(given = "Karl", family = "Ropkins", role = | ||
c("aut"), email = "k.ropkins@its.leeds.ac.uk", comment = c(ORCID = | ||
"0000-0002-0294-6997")) ) | ||
Authors@R: c( person(given = "Sergio", family = "Ibarra-Espinosa", role = c("aut", "cre"), email = | ||
"sergio.ibarra@usp.br", comment = c(ORCID = "0000-0002-3162-1905")), person(given = "Karl", | ||
family = "Ropkins", role = c("aut"), email = "k.ropkins@its.leeds.ac.uk", comment = c(ORCID = | ||
"0000-0002-0294-6997")) ) | ||
License: MIT + file LICENSE | ||
URL: https://github.com/atmoschem/respeciate | ||
BugReports: https://github.com/atmoschem/respeciate/issues | ||
LazyData: yes | ||
Depends: R (>= 3.5.0) | ||
RoxygenNote: 7.3.1 | ||
RoxygenNote: 7.3.2 | ||
Encoding: UTF-8 | ||
Imports: data.table, lattice, latticeExtra |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
#' @keywords internal | ||
#' @name respeciate-package | ||
#' @aliases respeciate | ||
"_PACKAGE" | ||
NULL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
#' @name rsp.combine | ||
#' @title combining respeciate profiles | ||
#' @aliases rsp_lbind | ||
|
||
#' @description Functions to combining respeciate data sets. | ||
|
||
#' @description \code{rsp_lbind} binds two or more \code{respeciate}-like | ||
#' objects. The default option is to stack the supplied data sets (e.g. | ||
#' \code{respeciate}, \code{data.frame}, etc) like \code{rbindlist} | ||
#' in \code{data.table} (or row_bind in dplyr). This matches columns by name | ||
#' before stacking the supplied data sets. | ||
|
||
#' @param ... (various) This function is intended to be quite flexible. All | ||
#' supplied arguments are tested and handled as follows: \code{respeciate}-like | ||
#' objects are passed to \code{data.table::rbindlist} as a list to rbind using | ||
#' \code{data.table} methods; Any other arguments that are valid | ||
#' \code{rbindlist} arguments are passed on 'as is'; And, anything else is | ||
#' (hopefully) ignored. | ||
|
||
#' @return \code{rsp_lbind} attempts to return a single stacked version of the | ||
#' supplied data sets. If it is successful, the (stacked) data set is typically | ||
#' returned as a \code{respeciate} object or a \code{data.frame} with a warning | ||
#' if it is missing columns \code{respeciate} expects. | ||
|
||
## #' @note | ||
## TO DO: want a statement here about why we are not going with a rbind method | ||
## basically, it is a pain... | ||
## ... if any of the data sets is a data.frame, and | ||
## you get rbind.data.frame/default | ||
## is some online discussion of its behaviour | ||
|
||
## #' @seealso [link to data.table::rbindlist if we can do that...] | ||
## not sure I am loading package | ||
|
||
#' @references | ||
#' Dowle M, Srinivasan A (2023). data.table: Extension of `data.frame`. | ||
#' R package version 1.14.8, \url{https://CRAN.R-project.org/package=data.table}. | ||
|
||
########################################## | ||
# general NOTES | ||
########################################## | ||
|
||
# not loading all of data.table, see xxx.r... | ||
|
||
###################### | ||
#rsp_lbind | ||
###################### | ||
|
||
#' @rdname rsp.combine | ||
#' @export | ||
|
||
#issues | ||
############################ | ||
|
||
# not finished | ||
|
||
# bits of documentation to complete | ||
# links to data.table::rbindlist need to be added | ||
# in text and see also | ||
# error messages need tidying | ||
# currently not handling the class quite right | ||
# ok for standard respeciate object, | ||
# probably not for rsp_x | ||
# definitely not for wides... | ||
# stack, but probably breaks respeciate rules for | ||
# data.frame, etc without expected respeciate names .... ? | ||
# (see notes in function) | ||
|
||
#think about... | ||
############################# | ||
|
||
# might need option to force object class | ||
# option(s) to make errors/warning silent ???? | ||
# could we extend lbind to do cbind as well as rbind ???? | ||
# could we extend lbind to do merge as well ??? | ||
|
||
rsp_lbind <- function(...){ | ||
|
||
# setup | ||
##################################### | ||
.args <- list(...) | ||
|
||
# ... handling 1: the data.sets | ||
##################################### | ||
# based on method in rsp() method v 0.3 | ||
# allows data.frames, respeciate objects, etc | ||
.rsp <- lapply(.args, function(.rsp){ | ||
if(is.data.frame(.rsp)){ .rsp }}) | ||
|
||
#might want to think about respeciate handling ??? | ||
# if for example something is wide ???? or rsp_x ???? | ||
|
||
# rbindlist | ||
################################### | ||
# currently using loa-like approach... | ||
# allowing only extra args formally declared in rbindlist | ||
.refs <- names(formals(data.table::rbindlist)) | ||
.lbind <- modifyList(list(l=.rsp, fill=TRUE), | ||
.args[names(.args) %in% .refs]) | ||
.bound.dt <- do.call(data.table::rbindlist, .lbind) | ||
if(nrow(.bound.dt)==0){ | ||
stop("RSP> Nothing to list and rbind...", | ||
call. = FALSE) | ||
} | ||
|
||
# output | ||
########################### | ||
|
||
# should this try to force class to that of first data set in call ??? | ||
# might make most sense ??? | ||
|
||
.rsp <- try(as.respeciate(.bound.dt), silent=TRUE) | ||
if(class(.rsp)[1]=="try-error"){ | ||
warning("RSP> not obvious respeciate; returning as data.frame...", | ||
call. = FALSE) | ||
as.data.frame(.bound.dt) | ||
} else { | ||
.rsp | ||
} | ||
} | ||
|
||
|
||
|
Oops, something went wrong.