Skip to content

Commit

Permalink
add a bunch of roxygen examples
Browse files Browse the repository at this point in the history
  • Loading branch information
lschneiderbauer committed Dec 27, 2024
1 parent 7db2aac commit c164605
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 19 deletions.
20 changes: 10 additions & 10 deletions R/fcwt.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,14 @@
#' @examples
#' ts_sin_440 <- sin((1:5000) * 2 * pi * 440 / 44100)
#'
#' res <-
#' fcwt(
#' ts_sin_440,
#' sample_freq = u(44.1, "kHz"),
#' freq_begin = u(50, "Hz"),
#' freq_end = u(1000, "Hz"),
#' n_freqs = 10,
#' sigma = 5
#' )
#' fcwt(
#' ts_sin_440,
#' sample_freq = u(44.1, "kHz"),
#' freq_begin = u(50, "Hz"),
#' freq_end = u(1000, "Hz"),
#' n_freqs = 10,
#' sigma = 5
#' )
#' @export
fcwt <- function(signal,
sample_freq,
Expand Down Expand Up @@ -134,7 +133,8 @@ fcwt <- function(signal,

sc <-
fcwtr_scalogram(
output, time_offset = u(0, "s"), sample_freq, freq_begin, freq_end,
output,
time_offset = u(0, "s"), sample_freq, freq_begin, freq_end,
freq_scale, sigma
)

Expand Down
35 changes: 35 additions & 0 deletions R/fcwtr_scalogram.R
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,26 @@ sc_agg <- function(x, wnd) {
#'
#' @return Returns a new time-wise combined "fcwtr_scalogram" object.
#'
#' @examples
#' ts_sin_440 <- sin((1:5000) * 2 * pi * 440 / 44100)
#'
#' res <-
#' fcwt(
#' ts_sin_440,
#' sample_freq = u(44.1, "kHz"),
#' freq_begin = u(50, "Hz"),
#' freq_end = u(1000, "Hz"),
#' n_freqs = 10,
#' sigma = 5
#' )
#'
#' print(res)
#'
#' # doubled scalogram
#' res_doubled <- rbind(res, res)
#'
#' print(res_doubled)
#'
#' @export
rbind.fcwtr_scalogram <- function(...) {
args <- list(...)
Expand Down Expand Up @@ -322,6 +342,14 @@ as.data.frame.fcwtr_scalogram <- function(x, ...) {
#' An "fcwtr_scalogram" object resulting from [fcwt()].
#' @inheritParams base::as.matrix
#'
#' @examples
#' fcwt(
#' sin((1:5000) * 2 * pi * 440 / 44100),
#' sample_freq = 44100,
#' n_freqs = 10
#' ) |>
#' as.matrix()
#'
#' @export
as.matrix.fcwtr_scalogram <- function(x, ...) {
attributes(x) <- NULL
Expand Down Expand Up @@ -352,6 +380,13 @@ as.matrix.fcwtr_scalogram <- function(x, ...) {
#' @return
#' Another "fcwtr_scalogram" object that contains only part of the data.
#'
#' @examples
#' fcwt(
#' sin((1:5000) * 2 * pi * 440 / 44100),
#' sample_freq = 44100,
#' n_freqs = 10
#' )[1:1000, 2:7]
#'
#' @export
`[.fcwtr_scalogram` <- function(x, i, j) {
if (!missing(i)) {
Expand Down
9 changes: 9 additions & 0 deletions man/as.matrix.fcwtr_scalogram.Rd

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

17 changes: 8 additions & 9 deletions man/fcwt.Rd

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

21 changes: 21 additions & 0 deletions man/rbind.fcwtr_scalogram.Rd

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

8 changes: 8 additions & 0 deletions man/sub-.fcwtr_scalogram.Rd

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

0 comments on commit c164605

Please sign in to comment.