Rev 42333 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
% File src/library/utils/man/read.DIF.Rd% Part of the R package, http://www.R-project.org% Copyright 1995-2007 R Core Development Team% Distributed under GPL 2 or later\name{read.DIF}\alias{read.DIF}\title{Data Input from Spreadsheet}\description{Reads a file in Data Interchange Format (DIF) and creates a data framefrom it. DIF is a format for data matrices such as single spreadsheets.}\usage{read.DIF(file, header = FALSE,dec = ".", row.names, col.names,as.is = !stringsAsFactors,na.strings = "NA", colClasses = NA, nrows = -1,skip = 0, check.names = TRUE,blank.lines.skip = TRUE,stringsAsFactors = default.stringsAsFactors())}\arguments{\item{file}{the name of the file which the data are to be read from,or a connection, or a complete URL.#ifdef windowsThe name \code{"clipboard"} may also be used on Windows, in whichcase \code{read.DIF("clipboard")} will look for a DIF format entryin the Windows clipboard.#endif}\item{header}{a logical value indicating whether the spreadsheet contains thenames of the variables as its first line. If missing, the value isdetermined from the file format: \code{header} is set to \code{TRUE}if and only if the first row contains only character values andthe top left cell is empty.}\item{dec}{the character used in the file for decimal points.}\item{row.names}{a vector of row names. This can be a vector givingthe actual row names, or a single number giving the column of thetable which contains the row names, or character string giving thename of the table column containing the row names.If there is a header and the first row contains one fewer field thanthe number of columns, the first column in the input is used for therow names. Otherwise if \code{row.names} is missing, the rows arenumbered.Using \code{row.names = NULL} forces row numbering.}\item{col.names}{a vector of optional names for the variables.The default is to use \code{"V"} followed by the column number.}\item{as.is}{the default behavior of \code{read.DIF} is to convertcharacter variables (which are not converted to logical, numeric orcomplex) to factors. The variable \code{as.is} controls theconversion of columns not otherwise specified by \code{colClasses}.Its value is either a vector of logicals (values are recycled ifnecessary), or a vector of numeric or character indices whichspecify which columns should not be converted to factors.Note: to suppress all conversions including those of numericcolumns, set \code{colClasses = "character"}.Note that \code{as.is} is specified per column (not pervariable) and so includes the column of row names (if any) and anycolumns to be skipped.}\item{na.strings}{a character vector of strings which are to beinterpreted as \code{\link{NA}} values. Blank fields are alsoconsidered to be missing values in logical, integer, numeric andcomplex fields.}\item{colClasses}{character. A vector of classes to be assumed forthe columns. Recycled as necessary, or if the character vector isnamed, unspecified values are taken to be \code{NA}.Possible values are \code{NA} (when \code{\link{type.convert}} isused), \code{"NULL"} (when the column is skipped), one of the atomicvector classes (logical, integer, numeric, complex, character, raw),or \code{"factor"}, \code{"Date"} or \code{"POSIXct"}. Otherwisethere needs to be an \code{as} method (from package \pkg{methods})for conversion from \code{"character"} to the specified formalclass.Note that \code{colClasses} is specified per column (not pervariable) and so includes the column of row names (if any).}\item{nrows}{the maximum number of rows to read in. Negative valuesare ignored.}\item{skip}{the number of lines of the data file to skip beforebeginning to read data.}\item{check.names}{logical. If \code{TRUE} then the names of thevariables in the data frame are checked to ensure that they aresyntactically valid variable names. If necessary they are adjusted(by \code{\link{make.names}}) so that they are, and also to ensurethat there are no duplicates.}\item{blank.lines.skip}{logical: if \code{TRUE} blank lines in theinput are ignored.}\item{stringsAsFactors}{logical: should character vectors be convertedto factors?}}\value{A data frame (\code{\link{data.frame}}) containing a representation ofthe data in the file. Empty input is an error unless \code{col.names}is specified, when a 0-row data frame is returned: similarly givingjust a header line if \code{header = TRUE} results in a 0-row data frame.}\note{The columns referred to in \code{as.is} and \code{colClasses} includethe column of row names (if any).Less memory will be used if \code{colClasses} is specified as one ofthe six atomic vector classes.}\seealso{The \emph{R Data Import/Export} manual.\code{\link{scan}}, \code{\link{type.convert}},\code{\link{read.fwf}} for reading \emph{f}ixed \emph{w}idth\emph{f}ormatted input;\code{\link{read.table}};\code{\link{data.frame}}.}\references{The DIF format specification can be found by searching on\url{http://www.wotsit.org/}; the optional header fields are ignored.See also\url{http://en.wikipedia.org/wiki/Data_Interchange_Format}.The term is likely to lead to confusion: Windows will have a\sQuote{Windows Data Interchange Format (DIF) data format} as part ofits WinFX system, which may or may not be compatible.}\keyword{file}\keyword{connection}