Write a Data Frame to an External File

DESCRIPTION:

Writes a data frame or matrix to an opened external file. Each call to the function appends the data frame or matrix to the external file. The function closeData closes the external file when the user is finished writing to it.

USAGE:

writeNextDataRows(dh, data)

REQUIRED ARGUMENTS:

dh
a data handle object to an external data file. This is created with openData.
data
a data frame or matrix to be writing to the external data file.

VALUE:

the number of rows written to the external file.

DETAILS:

The function closeData is used to close the external file after writing all data.

When writing out character data, the values in a column are truncated to the maximum string length for that column that is written out in the first block.

SEE ALSO:

, , .

EXAMPLES:

# Open an external data file of type SAS
dh <- openData("randnorm.ssd01", type="SAS", openType="write")
# Write out blocks of random normals, 10 rows at a time
for(i in 1:10) {
        x <- matrix(rnorm(50), ncol=5)
        writeNextDataRows(dh, x)
}
closeData(dh)
# Now read the all 100 rows back in
z <- importData("randnorm.ssd01", colNames=paste("Z",1:5,sep=''))