R/convert_legacy.R

Defines functions convert_legacy.vpts convert_legacy.vp convert_legacy

Documented in convert_legacy convert_legacy.vp convert_legacy.vpts

#' Convert legacy bioRad objects
#'
#' Convert legacy bioRad objects (`vp`, `vpts`) and make them compatible with
#' the current bioRad version. Conversion includes renaming `HGHT` to `height`.
#'
#' @param x A `vp` or `vpts` object.
#'
#' @return An updated object of the same class as the input.
#'
#' @export
#'
#' @seealso
#' * [summary.vp()]
#' * [summary.vpts()]
#'
#' @examples
#' # Convert a vp object
#' vp <- convert_legacy(example_vp)
#'
#' # Convert a vpts object
#' vpts <- convert_legacy(example_vpts)
convert_legacy <- function(x) {
  UseMethod("convert_legacy", x)
}

#' @rdname convert_legacy
#'
#' @export
convert_legacy.vp <- function(x) {
  assertthat::assert_that(inherits(x, "vp"))
  names(x$data) <- sub("HGHT", "height", names(x$data))
  x
}

#' @rdname convert_legacy
#'
#' @export
convert_legacy.vpts <- function(x) {
  assertthat::assert_that(inherits(x, "vpts"))
  names(x) <- sub("heights", "height", names(x))
  names(x) <- sub("dates", "datetime", names(x))
  x
}

Try the bioRad package in your browser

Any scripts or data that you put into this service are public.

bioRad documentation built on Oct. 20, 2023, 5:06 p.m.