rtapeRerecord {rtape}R Documentation

Rerecord the tape.

Description

Rerecord the tape.

Usage

rtapeRerecord(FUN, fNamesIn, fNameOut=fNamesIn, moreArgs, skipNULLs=FALSE,
    fileFormatOut=guessFileFormat(fNameOut))

Arguments

FUN

Callback function which transforms the objects.

fNamesIn

Name of the tape file to read; if this argument is a vector of several names, function behaves as reading a single tape made of all those tapes joined in a given order.

fNameOut

Name of the tape to which store the output of filtering; if this file is one of the input files, this file is overwritten with the output; otherwise the output is appended to this tape. This must be a one-element vector.

moreArgs

Additional arguments to FUN, given as a list.

skipNULLs

If true, all the NULLs returned by FUN are not appended to the output. Useful to remove some objects from the tape; see rtapeFilter for convenience function to do just this task.

fileFormatOut

File format; should be left default. See guessFileFormat and makeFileFormat for details.

Details

This function reads the objects from one tape, executes a callback function on them and updates them with/appends to the other tape the objects that the callback has returned.

Note

Overwriting is NOT realised in place, rather by a creation of a temporary file and then using it to overwrite the filtered tape.

Author(s)

Miron B. Kursa M.Kursa@icm.edu.pl

Examples

unlink(c('tmp.tape','tmp2.tape'))
#Record something
for(i in 1:10) rtapeAdd('tmp.tape',i)

#Multiply each object by two
rtapeRerecord('*','tmp.tape','tmp2.tape',moreArgs=list(2))

#Check it out
unlist(rtapeAsList('tmp.tape'))->A
B<-unlist(rtapeAsList('tmp2.tape'))
print(A);print(B)
stopifnot(all(A==B/2))

#Now do the same in-place:
rtapeRerecord('*','tmp.tape',moreArgs=list(2))
unlist(rtapeAsList('tmp.tape'))->B2
stopifnot(all(A==B2/2))

#Time to clean up
unlink(c('tmp.tape','tmp2.tape'))

[Package rtape version 2.2 Index]