R/catch_matrix.R

Defines functions catch_matrix

Documented in catch_matrix

catch_matrix <- function(x, z=NULL, y, testx=NULL,testz=NULL,...){
  #input x is matrix * size
  pred = NULL
  nobs=length(y)
  nvars=prod(dim(x))/nobs
  nclass=length(unique(as.factor(y)))
  
  ntrain=dim(x)[3]
  newx=array(list(),ntrain)
  for (i in 1:ntrain){
    newx[[i]]=x[,,i]
  }
  newtestx=NULL
  if (!is.null(testx)){
    ntest=dim(testx)[3]
    newtestx=array(list(),ntest)
    for (i in 1:ntest){
      newtestx[[i]]=testx[,,i]
    }
  }
  catch(newx,z,y,newtestx,testz,...)
  
}

Try the catch package in your browser

Any scripts or data that you put into this service are public.

catch documentation built on Jan. 13, 2021, 4:04 p.m.