Learn R Programming

lessR (version 2.1.1)

out: Write the Contents of Data Frame mydata to a csv File

Description

Writes the contents of the data frame called mydata to a csv data file with a default name of mydata.csv to the current working directory. The purpose of out is to save some keyboard entry, speeding up the process of writing a csv data file and reducing entry mistakes.

Usage

out(myfile="mydata.csv")

Arguments

myfile
File reference, either null to specify the default of mydata.csv, or a specified character string.

Details

out runs the R statement write.csv(mydata, file=myfile, row.names=FALSE) 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.

out is designed to work in conjunction with the function rad from this package, which reads a csv file into the data frame mydata.

See Also

write.csv, rad.

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)

# write the contents of a data frame called mydata
#   into a csv file called "mydata.csv" in the working directory
# out()

# same as above, but specify the name of the output file name
out("mybestdata.csv")

Run the code above in your browser using DataLab