WriteFindings {RNetica} | R Documentation |
This function writes the current findings for a network as a row in a Netica case file. If filename already exists, the new row is appended on the end of the file. Variables that are not instantiated are written out using the missing code.
WriteFindings(nodes, pathOrStream, id = -1L, freq = -1.0)
nodes |
The a list of active |
pathOrStream |
Either a character scalar giving the path name of
the file to which the results are to be written, or a
|
id |
An integer scalar giving the case ID. The default value of
|
freq |
An integer scalar giving the number of cases with the
currently instantiated set of findings. The default value |
A case file is a table where the rows represent cases, and the columns
represent variables. WriteFindings
writes out the
currently instantiated value of the nodes in nodeset. If a
node in nodeset does not currently have a finding attached,
then the value of CaseFileMissingCode()
is printed out
instead. The values in the columns are separated by the value of
CaseFileDelimiter()
.
There are two special columns in the file. The column “IDnum”
is set to the value id
, which should contain an integer case
number. The column “NumCases” is set to the value of
freq
which should give a weight to assign to the case (in
various algorithms when freq
is supplied, it is treated as if
that case was repeated weight
times). Assigning either of
these fields a value of -1
means the corresponding column is
appended to the output.
The function WriteFindings
will create a new file
associated with filename
if it does not exist. In that case it
will write out a header row containing the variable names followed by
the current findings as the first case row. Subsequent calls to
WriteFindings
with the same filename
append
additional rows to the end of the file. In such cases, the
nodelist
should be the same, and if id
or freq
was -1
, it should be in the following calls as well.
Returns the caseOrStream argument invisibly. Note that the
values of getCaseStreamPos(stream)
,
getCaseStreamLastId(stream)
, and
getCaseStreamLastFreq(stream)
will be updated to reflect
the values from the last read record.
Russell G. Almond
http://norsys.com/onLineAPIManual/index.html: WriteNetFindings_bn()
CaseFileDelimiter
, CaseFileMissingCode
,
NodeFinding
, RetractNetFindings
ReadFindings
, CaseStream
sess <- NeticaSession() startSession(sess) abc <- CreateNetwork("ABC", session=sess) A <- NewDiscreteNode(abc,"A",c("A1","A2","A3","A4")) B <- NewDiscreteNode(abc,"B",c("B1","B2","B3")) C <- NewDiscreteNode(abc,"C",c("C1","C2")) AddLink(A,B) AddLink(A,C) AddLink(B,C) ## Outputfilename casefile <- tempfile("testcase",fileext=".cas") filestream <- CaseFileStream(casefile, session=sess) stopifnot(is.CaseFileStream(filestream), isCaseStreamOpen(filestream)) ## Case 1 NodeFinding(A) <- "A1" NodeFinding(B) <- "B1" NodeFinding(C) <- "C1" WriteFindings(list(A,B,C),casefile,1) RetractNetFindings(abc) ## Case 2 NodeFinding(A) <- "A2" NodeFinding(B) <- "B2" NodeFinding(C) <- "C2" WriteFindings(list(A,B,C),casefile,2) RetractNetFindings(abc) ## Case 3 NodeFinding(A) <- "A3" NodeFinding(B) <- "B3" ## C will be missing WriteFindings(list(A,B,C),casefile,3) RetractNetFindings(abc) DeleteNetwork(abc) stopSession(sess)