Cfrag.list | R Documentation |
Writes either the C declaration of items in a list, or initializes them with the contents of the list.
Cfrag.list(x, file = NULL, item.num = c(3, 10, 5), indent = c("\t", "\t\t"), declaration.only = FALSE, long = FALSE, append = FALSE)
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 |
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.
if file
is a non-empty character string, then the file is created,
overwritten or appended.
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.
Rcpp now probably makes most uses of this function obsolete.
.C
, storage.mode
, as.double
,
as.integer
, as.character
, cat
.
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)