Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

write.list

Output and Write a List Object


Description

Print or write its required argument z to a file

Usage

write.list(z, file, t.name = NULL, row.names = FALSE, ...)

Arguments

z

A list object to be written. Each item in the list is perferably a data frame. If not, it is converted into a data frame. All the contents are coerced into characters to avoid loss of information (e.g., a loss of zero in 5.130.

file

a character string naming a file.

t.name

table names. This can be given explicitly, or given by the list name, or by default, named as "table 1" for the first item in z.

row.names

whether the row names in each table should be written (default is FALSE). If TRUE, a new column of the row names is added to each table.

...

Other arguments that can be passed to write.table

Details

This function is a wrap-up of write.table. It is convenient to write a set of tables to C drive.

See Also

Examples

h1 <- ts(data=cbind(1:24), start=c(2001, 1), frequency=12)
h2 <- ts(data=cbind(1:24, 25:48), start=c(2001, 1), frequency=12)
h3 <- ts(data=cbind(1:4, 5:8, 9:12), start=c(2001, 1), frequency=4)
colnames(h2) <- c("aa", "bb")
colnames(h3) <- c("cc", "dd", "ee")
h1; h2; h3

test <- list(t1 = h1, t2 = h2, t3 = h3)

## Not run: 
  # test.csv can be saved at a specific working directory
  getwd(); setwd("c:/aERER"); getwd()
  write.list(z = test, file = "test.csv")

## End(Not run)

erer

Empirical Research in Economics with R

v3.0
GPL (>= 2)
Authors
Changyou Sun <cs258@msstate.edu>
Initial release
2020-04-30

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.