approxTime              package:simecol              R Documentation

_L_i_n_e_a_r _I_n_t_e_r_p_o_l_a_t_i_o_n _w_i_t_h _C_o_m_p_l_e_t_e _M_a_t_r_i_c_e_s _o_r _D_a_t_a _F_r_a_m_e_s

_D_e_s_c_r_i_p_t_i_o_n:

     Return a data frame, matrix or vector which linearly interpolates
     data from a given matrix or data frame.

_U_s_a_g_e:

     approxTime(x, xout, ...)
     approxTime1(x, xout, rule = 1)

_A_r_g_u_m_e_n_t_s:

       x: a matrix or data frame with numerical values giving
          coordinates of points to be interpolated. The first column is
          interpreted as independend variable (e.g. time), the
          remaining columns as dependend variables.  

    xout: a vector (or single value for 'approxTime1') of independend
          values specifying where interpolation has to be done.  

    rule: an integer describing how interpolation is to take place
          outside the interval [min(x), max(x)]. If 'rule' is 1 then
          'NA's are returned for such points and if it is 2, the value
          at the closest data extreme is used.  

     ...: optional parameters passed to 'approx'.

_D_e_t_a_i_l_s:

     The functions can be used for linear interpolation with a complete
     matrix or data frame. This can be used for example in the main
     function of an 'odeModel' to get input values at a specified time
     'xout'. The version 'approxTime1' is less flexible (only one
     single value for xout and only linear interpolation) but has
     increased performance.  Both functions are faster if 'x' is a
     matrix instead of a data frame.

_V_a_l_u_e:

     'approxTime' returns a matrix resp. data frame of the same
     structure as 'x' containing data which interpolate the given data
     with respect to 'xout'.  'approxTime1' is a performance optimized
     special version with less options than the original 'approx'
     function. It returns an interpolated vector.

_S_e_e _A_l_s_o:

     'approxfun'

_E_x_a_m_p_l_e_s:

     inputs <- data.frame(time = 1:10, y1 = rnorm(10), y2 = rnorm(10, mean = 50))
     input  <- approxTime(inputs, c(2.5, 3), rule = 2)

