Skip to content

Commit

Permalink
rebuildSPC: enforce aqp_df_class; possibly changed by aqp_df_class<- #…
Browse files Browse the repository at this point in the history
  • Loading branch information
brownag committed Sep 30, 2020
1 parent 4a473fa commit c39ecf1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions R/Class-SoilProfileCollection.R
Original file line number Diff line number Diff line change
Expand Up @@ -1316,6 +1316,19 @@ setMethod(f = 'aqp_df_class', signature(object = 'SoilProfileCollection'),

return(u)
})
if (!isGeneric("aqp_df_class<-"))
setGeneric("aqp_df_class<-", function(object, ...)
standardGeneric("aqp_df_class<-"))
#' @param value "data.frame", "data.table" or "tibble"
#' @rdname aqp_df_class
setReplaceMethod("aqp_df_class", signature(object = "SoilProfileCollection"),
function(object, value) {
if (!value %in% c('data.frame',"data.table","tibble"))
stop("aqp_df_class metadata entry must be data.frame, data.table or tibble",
call.=FALSE)
metadata(object)$aqp_df_class <- value
return(object)
})

#' Get depth units from metadata
#'
Expand Down
2 changes: 1 addition & 1 deletion R/rebuildSPC.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ rebuildSPC <- function(x) {
x.list <- suppressWarnings(as(x, 'list'))

# seed object for new SPC
res <- x.list$horizons
res <- .as.data.frame.aqp(x.list$horizons, aqp_df_class(x))

# init SPC from pieces
# note: using depths<- because it will generate a horizon ID
Expand Down

0 comments on commit c39ecf1

Please sign in to comment.