checkData        package:PerformanceAnalytics        R Documentation

_c_h_e_c_k _i_n_p_u_t _d_a_t_a _t_y_p_e _a_n_d _f_o_r_m_a_t _a_n_d _c_o_e_r_c_e _t_o _t_h_e _d_e_s_i_r_e_d _o_u_t_p_u_t _t_y_p_e

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

     This function was created to make the different kinds of data
     classes at least emph{seem} more fungible.  It allows the user to
     pass in a data object without being concerned that the function
     requires a matrix, data.frame, or timeSeries object.  By using
     this, the function "knows" what data format it has to work with.

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

     checkData(x, method = c("zoo","matrix","vector"), na.rm = FALSE, quiet = TRUE, ...)
     checkDataMatrix(x, na.rm = TRUE, quiet = TRUE, ...)
     checkDataVector(x, na.rm = TRUE, quiet = TRUE, ...)
     checkDataZoo(x, na.rm = TRUE, quiet = TRUE, ...)

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

       x: a vector, matrix, data frame, timeSeries or zoo object to be
          checked and coerced 

   na.rm: TRUE/FALSE Remove NA's from the data? 

   quiet: TRUE/FALSE if false, it will throw warnings when errors are
          noticed, default TRUE 

  method: type of coerced data object to return, one of
          c("zoo","matrix","vector"), default "zoo" 

     ...: any other passthru parameters 

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

     The 'checkData' function grew out of three older functions:
     'checkDataMatrix','checkDataVector', and 'checkDataZoo'.  All
     three of these functions are provided as wrappers to 'checkData'
     for backwards compatibility and for clarity inside existing code. 
     It is worth noting that the older checkData* functions set
     'na.rm=TRUE' by default.  The user is free to specify a value for
     this parameter to change the behavior.

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

     checkDataMatrix returns a data.frame

     checkDataVector returns a vector

     checkDataZoo returns a zoo object

     checkData will make a reasonable assumption, or return the object
     requested by method

_A_u_t_h_o_r(_s):

     Peter Carl

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

     data(edhec)
     x = checkData(edhec)
     class(x)
     head(x)
     tail(x)
     # Note that passing in a single column loses the row and column names
     x = checkData(edhec[,1])
     class(x)
     head(x)
     # Include the "drop" attribute to keep row and column names
     x = checkData(edhec[,1,drop=FALSE])
     class(x)
     head(x)
     x = checkData(edhec, method = "matrix")
     class(x)
     head(x)
     x = checkData(edhec[,1], method = "vector")
     class(x)
     head(x)

