Rev 30901 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
\name{dput}\alias{dput}\alias{dget}\title{Write an Internal Object to a File}\description{Writes an ASCII text representation of an \R object to a fileor connection, or uses one to recreate the object.}\usage{dput(x, file = "", control = "showAttributes")dget(file)}\arguments{\item{x}{an object.}\item{file}{either a character string naming a file or aconnection. \code{""} indicates output to the console.}\item{control}{character vector indicating deparsing options.See \code{\link{.deparseOpts}} for their description.}}\details{\code{dput} opens \code{file} and deparses the object \code{x} intothat file. The object name is not written (contrary to \code{dump}).If \code{x} is a function the associated environment is stripped.Hence scoping information can be lost.Deparsing an object is difficult, and not always possible. With thedefault \code{control = c("showAttributes")}, \code{dput()} attempts to deparse ina way that is readable, but for more complex or unusual objects, notlikely to be parsed as identical to the original. Use \code{control = "all"}for the most complete deparsing; use \code{control = NULL}for the simplest deparsing, not even including attributes.\code{dput} will warn if fewer characters were written to a file thanexpected, which may indicate a full or corrupt file system.To display saved source rather than deparsing the internal representationinclude \code{"useSource"} in \code{control}. \R currently saves source only forfunction definitions.}\note{To avoid the risk of a source attribute out of sync with the actualfunction definition, the source attribute of a function will neverbe written as an attribute.}\references{Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)\emph{The New S Language}.Wadsworth \& Brooks/Cole.}\seealso{\code{\link{deparse}}, \code{\link{dump}}, \code{\link{write}}.}\examples{## Write an ASCII version of mean to the file "foo"dput(mean, "foo")## And read it back into 'bar'bar <- dget("foo")unlink("foo")## Create a function with commentsbaz <- function(x) {# Subtract from one1-x}## and display itdput(baz)## and now display the saved sourcedput(baz, control = "useSource")}\keyword{file}\keyword{programming}\keyword{connection}