Learn R Programming

kvh (version 1.4.2)

obj2kvh: Writing/Adding an R Object to KVH File.

Description

Formats an object before writing it in kvh file.

Usage

obj2kvh(obj, objname = NULL, conct = stdout(), indent = 0)

Arguments

obj

an R object

objname

character object name to write in kvh file

conct

connection opened for writing

indent

is tab offset for object name

Value

None

Details

Scalar, vector, matrix and list are pre-processed. Other objects are written as an output string of toString() function To add a content to existent file use "a" as open mode fcn=file("m.kvh", "a") obj2kvh() can be used along the code advancing in the calculations. Writing in a subfield of an already started key requires use of appropriate indent value. The file is started with indent=0 and every sub-field increments the indent by 1. If objname is NULL and obj is not a scalar value, the content of obj is written in kvh file without additional indent.

Examples

Run this code
# NOT RUN {
m=matrix(1:6,2,3);
fcn=file("m.kvh", "w");
obj2kvh(m, "m", fcn);
close(fcn);
# clean
unlink("m.kvh")

# }

Run the code above in your browser using DataLab