File: utils.R

package info (click to toggle)
r-cran-opencv 0.5.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 444 kB
  • sloc: cpp: 777; sh: 80; makefile: 2
file content (16 lines) | stat: -rw-r--r-- 352 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
recoder <- function(x, from = c(), to = c()){
  if(length(x) == 0){
    return(x)
  }
  stopifnot(length(from) == length(to))
  nongiven <- unique(x[!is.na(x)])
  nongiven <- setdiff(nongiven, from)
  if(length(nongiven) > 0) {
    from <- append(x = from, values = nongiven)
    to   <- append(x = to, values = nongiven)
  }
  to[match(x, from)]
}