-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first draft of a tidy output function
- Loading branch information
Showing
3 changed files
with
99 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#' @name get_tidy_oxcalresult | ||
#' @title tidy output | ||
#' | ||
#' @description Transforms oxcAAR output to a tidy data format. | ||
#' See \url{http://vita.had.co.nz/papers/tidy-data.html} and | ||
#' \url{https://cran.r-project.org/web/packages/broom/vignettes/broom.html} | ||
#' | ||
#' @param x an object of class oxcAARCalibratedDate or oxcAARCalibratedDatesList | ||
#' | ||
#' @return a data.frame (with list columns) | ||
#' @export | ||
#' | ||
#' @rdname get_tidy_oxcalresult | ||
#' @examples | ||
#' \dontrun{ | ||
#' x <- oxcalCalibrate(c(5000, 4500, 3000), c(20, 50, 60)) | ||
#' get_tidy_oxcalresult(x) | ||
#' y <- oxcalCalibrate(5000, 20)[[1]] | ||
#' get_tidy_oxcalresult(y) | ||
#' } | ||
#' | ||
get_tidy_oxcalresult <- function(x) { | ||
UseMethod("get_tidy_oxcalresult") | ||
} | ||
|
||
#' @rdname get_tidy_oxcalresult | ||
#' @export | ||
get_tidy_oxcalresult.default <- function(x) { | ||
stop("x is not an object of class oxcAARCalibratedDate or oxcAARCalibratedDatesList") | ||
} | ||
|
||
#' @rdname get_tidy_oxcalresult | ||
#' @export | ||
get_tidy_oxcalresult.oxcAARCalibratedDate <- function(x) { | ||
res <- data.frame( | ||
name = get_name(x), | ||
bp = get_bp(x), | ||
std = get_std(x), | ||
cal_curve = get_cal_curve(x), | ||
sigma_ranges = I(list(get_sigma_ranges(x))), | ||
raw_probabilities = I(list(get_raw_probabilities(x))) | ||
) | ||
return(res) | ||
} | ||
|
||
#' @rdname get_tidy_oxcalresult | ||
#' @export | ||
get_tidy_oxcalresult.oxcAARCalibratedDatesList <- function(x) { | ||
res <- data.frame( | ||
name = get_name(x), | ||
bp = get_bp(x), | ||
std = get_std(x), | ||
cal_curve = get_cal_curve(x), | ||
sigma_ranges = I(get_sigma_ranges(x)), | ||
raw_probabilities = I(get_raw_probabilities(x)) | ||
) | ||
return(res) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.