Learn R Programming

Kmisc (version 0.5.0)

kSave: Write out and Save a Tabular File

Description

A function that both writes a file to table with write.table, and saves it with the same name but a separate file extension.

Usage

kSave(x, file, lvl = 1, Rext = ".rda", ...)

Arguments

x
the R object you want to save / write to file
file
the location to write the file to, with extension desired for object written by write.table
lvl
how many extensions do you want to strip from your output file?
Rext
the extension to use for the saved object.
...
optional arguments passed to write.table

Examples

Run this code
dat <- data.frame( x=c(1,2,3), y=c('a','b','c') )
kSave( dat, file="dat.txt" )
## the file 'dat.rda' is written as well - let's see if it exists
dat2 <- kLoad( "dat.rda" )
stopifnot( identical(dat, dat2) ) ## TRUE

Run the code above in your browser using DataLab