cache package:Biobase R Documentation _E_v_a_l_u_a_t_e _a_n _e_x_p_r_e_s_s_i_o_n _i_f _i_t_s _v_a_l_u_e _i_s _n_o_t _a_l_r_e_a_d_y _c_a_c_h_e_d. _D_e_s_c_r_i_p_t_i_o_n: Cache the evaluation of an expression in the file system. _U_s_a_g_e: cache(expr, dir=".", prefix="tmp_R_cache_", name) _A_r_g_u_m_e_n_t_s: expr: An expression of the form 'LHS <- RHS', Where 'LHS' is a variable name, 'RHS' is any valid expression, and '<-' must be used ('=' will not work). dir: A string specifying the directory into which cache files should be written (also where to go searching for an appropriate cache file). prefix: A string giving the prefix to use when naming and searching for cache files. The default is '"tmp_R_cache_"' name: Unused. This argument is present as a compatibility layer for the deprecated calling convention. _D_e_t_a_i_l_s: This function can be useful during the development of computationally intensive workflows, for example in vignettes or scripts. The function uses a cache file in 'dir' which defaults to the current working directory whose name is obtained by 'paste(prefix, name, ".RData", sep="")'. When 'cache' is called and the cache file exists, it is loaded and the object whose name is given on the left of '<-' in 'expr' is returned. In this case, 'expr' is _not_ evaluted. When 'cache' is called and the cache file does not exist, 'expr' is evaluted, its value is saved into a cache file, and then its value is returned. The 'expr' argument must be of the form of 'someVar <- {expressions}'. That is, the left hand side must be a single symbol name and the next syntactic token must be '<-'. To flush the cache and force recomputation, simply remove the cache files. You can use 'file.remove' to do this. _V_a_l_u_e: The (cached) value of 'expr'. _N_o_t_e: The first version of this function had a slightly different interface which is now deprecated (but still functional). The old version has arguments 'name' and 'expr' and the intended usage is: 'foo <- cache("foo", expr)'. _A_u_t_h_o_r(_s): Wolfgang Huber, huber@ebi.ac.uk Seth Falcon, sfalcon@fhcrc.org _E_x_a_m_p_l_e_s: bigCalc <- function() runif(10) cache(myComplicatedObject <- bigCalc()) aCopy <- myComplicatedObject remove(myComplicatedObject) cache(myComplicatedObject <- bigCalc()) stopifnot(all.equal(myComplicatedObject, aCopy)) allCacheFiles <- list.files(".", pattern="^tmp_R_cache_.*\.RData$", full.name=TRUE) file.remove(allCacheFiles)