# NOT RUN {
fil <- tempfile()
## Write an ASCII version of function mean to our temp file
dput(mean, fil)
## And read it back into 'bar'
bar <- dget(fil)
## Create a function with comments
baz <- function(x) {
# Subtract from one
1-x
}
## and display it
dput(baz)
## and now display the saved source
dput(baz, control = "useSource")
## Numeric values:
xx <- pi^(1:3)
dput(xx)
dput(xx, control = "digits17")
dput(xx, control = "hexNumeric")
dput(xx, fil); dget(fil) - xx # slight rounding on all platforms
dput(xx, fil, control = "digits17")
dget(fil) - xx # slight rounding on some platforms
dput(xx, fil, control = "hexNumeric"); dget(fil) - xx
unlink(fil)
xn <- setNames(xx, paste0("pi^",1:3))
dput(xn) # nicer, now "niceNames" being part of default 'control'
dput(xn, control = "S_compat") # no names
## explicitly asking for output as in R < 3.5.0:
dput(xn, control = c("keepNA", "keepInteger", "showAttributes"))
# }
Run the code above in your browser using DataLab