rtapeFilter: Rerecord the tape dropping certain objects.

Description Usage Arguments Details Note Author(s) Examples

Description

Rerecord the tape dropping certain objects.

Usage

1
2
rtapeFilter(FUN, fNamesIn, fNameOut=fNamesIn, moreArgs,
    fileFormatOut=guessFileFormat(fNameOut))

Arguments

FUN

Callback function which gets the current object and returns a boolean value that directs rtape to either keep (for TRUE) or discard it.

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.

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 leaves/appends to the other tape only those for which callback returned TRUE.

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
unlink(c('tmp.tape'))
#Record something
for(i in 1:10) rtapeAdd('tmp.tape',i)

#Discard even numbers
rtapeFilter(function(x) (x%%2)==1,'tmp.tape')

#Check it out
unlist(rtapeAsList('tmp.tape'))->A
print(A);
stopifnot(all(A==c(1,3,5,7,9)))

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

rtape documentation built on May 2, 2019, 9:18 a.m.

Related to rtapeFilter in rtape...