reframe_with_dct {tidynorm} | R Documentation |
Reframe with DCT
Description
Reframe data columns using the Discrete Cosine Transform
Usage
reframe_with_dct(
.data,
...,
.token_id_col = NULL,
.by = NULL,
.time_col = NULL,
.order = 5
)
Arguments
.data |
A data frame |
... |
|
.token_id_col |
|
.by |
|
.time_col |
A time column. |
.order |
The number of DCT parameters to return. If |
Details
This function will tidily apply the Discrete Cosine Transform with forward normalization (see dct for more info) to the targeted columns.
Identifying tokens
The DCT only works on a by-token basis, so there must be a column that
uniquely identifies (or, in combination with a .by
grouping, uniquely
identifies) each individual token. This column should be passed to
.token_id_col
.
Order
The number of DCT coefficients to return is defined by .order
. The default
value is 5. Larger numbers will lead to less smoothing when the Inverse
DCT is applied (see idct). Smaller numbers will lead to more smoothing.
If NA
is passed to .order
, all DCT parameters will be returned, which
when the Inverse DCT is supplied, will completely reconstruct the original
data.
Sorting by Time
An optional .time_col
can also be defined to ensure that the data is
correctly arranged by time.
Value
A data frame with with the targeted DCT coefficients, along with two additional columns
- .param
The nth DCT coefficient number
- .n
The number of original data values
Examples
library(tidynorm)
library(dplyr)
speaker_small <- filter(
speaker_tracks,
id == 0
)
speaker_dct <- reframe_with_dct(
speaker_small,
F1:F3,
.by = speaker,
.token_id_col = id,
.time_col = t
)
head(
speaker_dct
)