Reads the next block of rows from an external file.
USAGE:
readNextDataRows(dh)
REQUIRED ARGUMENTS:
dh
a data handle object to the external data file.
This is created with
openData.
VALUE:
a data frame created from the next block of data read from the external
data file that is referenced in the
dh.
The number of rows in the data frame will be the value
rowsToRead
specified in the call to
openData that created
dh
(or less if the last block of rows have been read).
SIDE EFFECTS:
When the last block of rows has been read the file associated with
dh
is closed.
SEE ALSO:
,
,
,
.
EXAMPLES:
# Create an external data set:
exportData(environmental,"env.sav") # an SPSS data file
# Open the external data set for subsequent reads:
dh <- openData("env.sav", rowsToRead=10)
# Compute the column means by accumulating sums in blocks of 10:
xsum <- 0; nobs <- 0
while(T) {
cat(nobs,"\n")
xdf <- readNextDataRows(dh)
# if length of xdf is 0, no more data to read
if(!length(xdf))
break
xsum <- xsum + colSums(xdf)
nobs <- nobs + nrow(xdf)
}
env.means <- xsum/nobs