1
0
Fork 0
mirror of https://github.com/sensebox/opensensmapr synced 2025-02-18 17:23:57 +01:00
opensensmapR/R/measurement_utils.R
2023-03-06 11:17:33 +01:00

25 lines
725 B
R

#' @export
plot.osem_measurements = function (x, ..., mar = c(2, 4, 1, 1)) {
oldpar <- par(no.readonly = TRUE)
on.exit(par(oldpar))
par(mar = mar)
plot(value~createdAt, x, col = factor(x$sensorId), xlab = NA, ylab = x$unit[1], ...)
invisible(x)
}
#' @export
print.osem_measurements = function (x, ...) {
print.data.frame(x, ...)
invisible(x)
}
#' Converts a foreign object to an osem_measurements data.frame.
#' @param x A data.frame to attach the class to.
#' Should have at least a `value` and `createdAt` column.
#' @return data.frame of class \code{osem_measurements}
#' @export
osem_as_measurements = function(x) {
ret = tibble::as_tibble(x)
class(ret) = c('osem_measurements', class(ret))
ret
}