R/get_values_at_time.R

get_values_at_times <- function( j , values , times , at , list = F , unique = T ){
  if(list==F){
    
  sapply( at , function( x ) {
    values[ , j ][ tail( which( sort( unique( times[ , j ] ) )  <= x ) , 1 ) ]
  }
  )
  }else{
    if(unique){      
      sapply( at , function( x ) {
    values[[j]][ tail( which( sort( ( times[[j]] ) )  <= x ) , 1 ) ] 
  }
  )
}else{
      
sapply( at , function( x ) {
    values[[j]][ tail( which( sort( unique( times[[j]] ) )  <= x ) , 1 ) ] 
  }
  )
}
  }
}

Try the MIICD package in your browser

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

MIICD documentation built on May 2, 2019, 11:01 a.m.