Skip to content

Commit

Permalink
added getter functions for oxcAARCalibratedDate - no tests for that yet
Browse files Browse the repository at this point in the history
  • Loading branch information
nevrome committed Jul 21, 2017
1 parent 251e505 commit e4af874
Show file tree
Hide file tree
Showing 8 changed files with 265 additions and 0 deletions.
6 changes: 6 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ S3method(print,oxcAARCalibratedDatesList)
export(R_Date)
export(R_Simulate)
export(executeOxcalScript)
export(get_bp)
export(get_cal_curve)
export(get_name)
export(get_raw_probabilities)
export(get_sigma_ranges)
export(get_std)
export(oxcAARCalibratedDate)
export(oxcalCalibrate)
export(oxcalSimulate)
Expand Down
115 changes: 115 additions & 0 deletions R/oxcAARCalibratedDate.R
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,118 @@ plotoxcAARDateSystemGraphics <- function(x, ...){
graphics::mtext(paste(x$cal_curve), side = 1, line = 4, adj = 0,
cex = 0.6)
}

#### getter ####

# helper function to check class attribute
check_if_class_is_oxcAARCalibratedDate <- function(x) {
if (!("oxcAARCalibratedDate" %in% class(x))) stop("x is not an object of class oxcAARCalibratedDate")
}

#' get date name
#'
#' @param x an object of class oxcAARCalibratedDate
#'
#' @return a string
#' @export
#'
#' @examples
#' \dontrun{
#' x <- oxcalCalibrate(5000, 20)[[1]]
#' get_name(x)
#' }
#'
get_name <- function(x) {
check_if_class_is_oxcAARCalibratedDate(x)
return(x[["name"]])
}

#' get date bp value (age)
#'
#' @param x an object of class oxcAARCalibratedDate
#'
#' @return an integer
#' @export
#'
#' @examples
#' \dontrun{
#' x <- oxcalCalibrate(5000, 20)[[1]]
#' get_bp(x)
#' }
#'
get_bp <- function(x) {
check_if_class_is_oxcAARCalibratedDate(x)
return(x[["bp"]])
}

#' get date std value (standard deviation)
#'
#' @param x an object of class oxcAARCalibratedDate
#'
#' @return an integer
#' @export
#'
#' @examples
#' \dontrun{
#' x <- oxcalCalibrate(5000, 20)[[1]]
#' get_std(x)
#' }
#'
get_std <- function(x) {
check_if_class_is_oxcAARCalibratedDate(x)
return(x[["std"]])
}

#' get calibration curve name
#'
#' @param x an object of class oxcAARCalibratedDate
#'
#' @return a string
#' @export
#'
#' @examples
#' \dontrun{
#' x <- oxcalCalibrate(5000, 20)[[1]]
#' get_cal_curve(x)
#' }
#'
get_cal_curve <- function(x) {
check_if_class_is_oxcAARCalibratedDate(x)
return(x[["cal_curve"]])
}

#' get sigma ranges
#'
#' @param x an object of class oxcAARCalibratedDate
#'
#' @return a list of three data.frames
#' @export
#'
#' @examples
#' \dontrun{
#' x <- oxcalCalibrate(5000, 20)[[1]]
#' get_sigma_ranges(x)
#' }
#'
get_sigma_ranges <- function(x) {
check_if_class_is_oxcAARCalibratedDate(x)
return(x[["sigma_ranges"]])
}

#' get raw probabilities
#'
#' @param x an object of class oxcAARCalibratedDate
#'
#' @return a data.frame
#' @export
#'
#' @examples
#' \dontrun{
#' x <- oxcalCalibrate(5000, 20)[[1]]
#' get_raw_probabilities(x)
#' }
#'
get_raw_probabilities <- function(x) {
check_if_class_is_oxcAARCalibratedDate(x)
return(x[["raw_probabilities"]])
}
24 changes: 24 additions & 0 deletions man/get_bp.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions man/get_cal_curve.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions man/get_name.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions man/get_raw_probabilities.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions man/get_sigma_ranges.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions man/get_std.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e4af874

Please sign in to comment.