Learn R Programming

DescTools (version 0.99.19)

XLView: Use Excel as Viewer for a Data.Frame

Description

XLView can be used to view and edit a data.frame directly in Excel, resp. to create a new data.frame in Excel.

Usage

XLView(x, col.names = TRUE, row.names = FALSE, na = "")
XLKill()

Arguments

x
is a data.frame to be transferred to Excel. If data is missing a new file will be created.

row.names
either a logical value indicating whether the row names of x are to be written along with x, or a character vector of row names to be written.
col.names
either a logical value indicating whether the column names of x are to be written along with x, or a character vector of column names to be written. See the section on 'CSV files' write.table for the meaning of col.names = NA.
na
the string to use for missing values in the data.

Value

Details

The data.frame will be exported in CSV format and then imported in Excel. Take care: Changes to the data made in Excel will NOT automatically be updated in the original data.frame. The user will have to read the csv-file into R again. See examples how to get this done. XLKill will kill a running XL instance (which might be invisible). Background is the fact, that the simple XL$quit() command would not terminate a running XL task, but only set it invisible (observe the TaskManager). This ghost version may sometimes confuse XLView and hinder to create a new instance. In such cases you have to do the garbage collection...

See Also

GetNewXL, XLGetRange, XLGetWorkbook

Examples

Run this code
## Not run: # Windows-specific example
# XLView(d.diamonds)
# 
# # edit an existing data.frame in Excel, make changes and save there, return the filename
# fn <- XLView(d.diamonds)
# # read the changed file and store in new data.frame
# d.frm <- read.table(fn, header=TRUE, quote="", sep=";")
# 
# # Create a new file, edit it in Excel...
# fn <- XLView()
# # ... and read it into a data.frame when in R again
# d.set <- read.table(fn, header=TRUE, quote="", sep=";")
# 
# # Export a ftable object, quite elegant...
# XLView(format(ftable(Titanic), quote=FALSE), row.names = FALSE, col.names = FALSE)
# ## End(Not run)

Run the code above in your browser using DataLab