lessR (version 2.5)

Write: Write the Contents of Data Frame mydata to an External File

Description

Abbreviation: wrt, wrt.r

Writes the contents of the data frame called mydata to to the current working directory as either the default csv data file or an R native data file.

Usage

Write(file="mydata", type=c("csv", "R"))

wrt(...)

wrt.r(..., type="R")

Arguments

file
File reference as a character string.
type
Type of file to be written with .csv as the default.
...
Other parameter values consistent with the usual write.table.

Details

Specify the file name without the file type, which wrt adds automatically, .csv for a comma separated values data file and .rda for a native R data file. The name of the file, as well as the name of the working directory into which the file was written, are displayed at the console.

wrt is designed to work in conjunction with the function Read from this package, which reads a csv, fixed width format, or native SPSS or R data files into the data frame mydata. wrt relies upon the R functions write.csv and save.

See Also

Read, write.csv, save.

Examples

Run this code
# create data frame called mydata
n <- 12
X <- sample(c("Group1","Group2"), size=n, replace=TRUE)
Y <- rnorm(n=n, mean=50, sd=10)
mydata <- data.frame(X,Y)

# specify the name of the output csv file
Write("mybestdata")
# short name
wrt("mybestdata")

# specify the name of the output native R data file
Write("mybestdata", type="R")

Run the code above in your browser using DataLab