From 033947bd97484b24ead7725ee58c1166aa208777 Mon Sep 17 00:00:00 2001 From: Lukas Schneiderbauer Date: Sat, 15 Jun 2024 13:12:15 +0200 Subject: [PATCH] add example to as.data.frame() --- R/fcwtr_scalogram.R | 9 +++++++++ man/as.data.frame.fcwtr_scalogram.Rd | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/R/fcwtr_scalogram.R b/R/fcwtr_scalogram.R index 60e92ee..93ef3c4 100644 --- a/R/fcwtr_scalogram.R +++ b/R/fcwtr_scalogram.R @@ -139,6 +139,15 @@ rm_na_time_slices <- function(x) { #' } #' #' @inheritParams base::as.data.frame +#' @examples +#' fcwt( +#' sin((1:5000) * 2 * pi * 440 / 44100), +#' sample_freq = 44100, +#' n_freqs = 10 +#' ) |> +#' as.data.frame() |> +#' head() +#' #' @export as.data.frame.fcwtr_scalogram <- function(x, ...) { df <- as.data.frame(as.table(x), stringsAsFactors = FALSE) diff --git a/man/as.data.frame.fcwtr_scalogram.Rd b/man/as.data.frame.fcwtr_scalogram.Rd index bf5f21f..cd2e605 100644 --- a/man/as.data.frame.fcwtr_scalogram.Rd +++ b/man/as.data.frame.fcwtr_scalogram.Rd @@ -28,3 +28,13 @@ Internally, the scalogram resulting from \code{\link[=fcwt]{fcwt()}} is represen a numeric matrix. This method coerces this matrix into a reasonable data frame. Note that this conversion has a significant run time cost. } +\examples{ +fcwt( + sin((1:5000) * 2 * pi * 440 / 44100), + sample_freq = 44100, + n_freqs = 10 +) |> +as.data.frame() |> +head() + +}