write.CaseFile {RNetica} | R Documentation |
These functions our wrapper around read.table
and
write.table
to format the file in the expected
Netica case file format.
write.CaseFile(x, file, ..., session=getDefaultSession()) read.CaseFile(file, ..., session=getDefaultSession())
x |
A data frame to be written to the file. See details. |
file |
A file name or a connection object. By convention, Netica expects case files to end in the “.cas” suffix. |
... |
Other arguments to |
session |
An object of class |
A Netica case file has a format that very much resembles the output of
write.table
. The first row is a header row, which
contains the names of the variables, the second and subsequent rows
contain a set of findings: an assignment of values to the nodes
indicated in the columns. There are no row numbers, and the separator
and missing value codes are the values of
CaseFileDelimiter()
, and
CaseFileMissingCode()
respectively.
In addition to columns representing variables, two special columns are
allowed. The column named “IDnum”, if present should contain
integers which correspond to ID numbers for the cases (this correspond
to the id
argument of WriteFindings
). The column
named “NumCases” should contain number values and this allows
rows to be differentially weighted (this correspond to the freq
argument of WriteFindings
). If these special arguments
are present, write.table
permutes the columns if necessary to
make them first in the order (as Netica does in WriteFindings
).
The function read.CaseFile
overrides following arguments of
read.table
: header = TRUE
, sep =
CaseFileDelimiter()
, and na.strings =
CaseFileMissingCode()
. The function write.CaseFile
overrides following arguments of write.table
: col.name =
TRUE
, row.names = FALSE
, quote = FALSE
, sep =
CaseFileDelimiter()
, and na =
CaseFileMissingCode()
.
The function read.CaseFile
returns a data frame containing the
information in the case file. The function write.CaseFile
returns the output of the write.table
call (which
is undocumented).
Russell Almond
CaseFileDelimiter
, CaseFileMissingCode
,
WriteFindings
, ReadFindings
,
CaseMemoryStream
,CaseFileStream
,
MemoryStreamContents
,
read.table
,write.table
sess <- NeticaSession() startSession(sess) casefile <- file.path(library(help="RNetica")$path, "testData","abctestcases.cas") CaseFileDelimiter("\t", session=sess) CaseFileMissingCode("*", session=sess) cases <- read.CaseFile(casefile, session=sess) outfile <- tempfile("testcase",fileext=".cas") write.CaseFile(cases,outfile, session=sess) stopSession(sess)