| Cfrag.list {BurStMisc} | R Documentation |
Write a Fragment of a C Program
Description
Writes either the C declaration of items in a list, or initializes them with the contents of the list.
Usage
Cfrag.list(x, file = NULL, item.num = c(3, 10, 5),
indent = c("\t", "\t\t"), declaration.only = FALSE,
long = FALSE, append = FALSE)
Arguments
x |
required. A list with names. |
file |
either |
item.num |
length three vector giving the number of items per line for doubles, integers and characters. |
indent |
length two vector giving the amount to indent declarations and the items in the initialization. |
declaration.only |
logical flag.
If |
long |
logical flag.
If |
append |
logical flag.
If |
Value
if file is a non-empty character string, then the name of the file
that is written.
Otherwise, a character vector of the declarations – each element representing
a different line.
Side Effects
if file is a non-empty character string, then the file is created,
overwritten or appended.
Details
The type to declare is dependent on the storage mode of the component of
x.
You may need to coerce components to get them to be declared the correct type.
Note
Rcpp now probably makes most uses of this function obsolete.
See Also
.C, storage.mode, as.double,
as.integer, as.character, cat.
Examples
test.list <- list(adoub=as.double(rnorm(20)), anint=as.integer(92:109),
achar=c("aaa", "bbbb", "ccccc"))
Cfrag.list(test.list, file="")
## Not run:
Cfrag.list(test.list, file="test.c")
Cfrag.list(test.list[1], file="test.c", dec=TRUE)
Cfrag.list(test.list[-1], file="test.c", dec=FALSE, append=TRUE)
## End(Not run)