Learn R Programming

parallelize.dynamic (version 0.9-1)

tempcodefile: Create a temporary file that contains the function definition of the argument.

Description

Create a temporary file that contains the function definition of the argument so that this file can be sourced to re-instantiate the function.

Usage

tempcodefile(fcts)

Arguments

fcts

Value

Returns the path to the file written.

Details

Create a temporary file that contains the function definition of the argument so that this file can be sourced to re-instantiate the function. The temporary file is written to the temporary folder of the current R session.

Examples

Run this code
  # code to be parallelized
  parallel8 = function(e) log(1:e) %*% log(1:e);
  parallel2 = function(e) rep(e, e) %*% 1:e * 1:e;
  parallel1 = function(e) Lapply(rep(e, 15), parallel2);
  parallel0 = function() {
    r = sapply(Lapply(1:50, parallel1),
      function(e)sum(as.vector(unlist(e))));
    r0 = Lapply(1:49, parallel8);
    r
  }

  codeFile = tempcodefile(c(parallel0, parallel1, parallel2, parallel8));
  cat(readFile(codeFile));

Run the code above in your browser using DataLab