File: up.sample.R

package info (click to toggle)
r-cran-waveslim 1.8.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,096 kB
  • sloc: ansic: 894; makefile: 2
file content (17 lines) | stat: -rw-r--r-- 468 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#' Upsampling of a vector
#' 
#' Upsamples a given vector.
#' 
#' 
#' @param x vector of observations
#' @param f frequency of upsampling; e.g, 2, 4, etc.
#' @param y value to upsample with; e.g., NA, 0, etc.
#' @return A vector twice its length.
#' @author B. Whitcher
#' @references Any basic signal processing text.
#' @keywords ts
#' @export up.sample
up.sample <- function(x, f, y=NA) {
  n <- length(x)
  as.vector(rbind(x, matrix(rep(y, (f-1)*n), nrow=f-1)))
}