read.DIF(file, header = FALSE, dec = ".", numerals = c("allow.loss", "warn.loss", "no.loss"), 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(), transpose = FALSE, fileEncoding = "")
The name "clipboard"
may also be used on Windows, in which
case read.DIF("clipboard")
will look for a DIF format entry
in the Windows clipboard.
header
is set to TRUE
if and only if the first row contains only character values and
the top left cell is empty.type.convert
. If there is a header and the first row contains one fewer field than
the number of columns, the first column in the input is used for the
row names. Otherwise if row.names
is missing, the rows are
numbered.
Using row.names = NULL
forces row numbering.
"V"
followed by the column number.read.DIF
is to convert
character variables to factors. The variable as.is
controls the
conversion of columns not otherwise specified by colClasses
.
Its value is either a vector of logicals (values are recycled if
necessary), or a vector of numeric or character indices which
specify which columns should not be converted to factors. Note: In releases prior to R 2.12.1, cells marked as being of
character type were converted to logical, numeric or complex using
type.convert
as in read.table
.
Note: to suppress all conversions including those of numeric
columns, set colClasses = "character"
.
Note that as.is
is specified per column (not per
variable) and so includes the column of row names (if any) and any
columns to be skipped.
NA
values. Blank fields are also
considered to be missing values in logical, integer, numeric and
complex fields.NA
. Possible values are NA
(when type.convert
is
used), "NULL"
(when the column is skipped), one of the atomic
vector classes (logical, integer, numeric, complex, character, raw),
or "factor"
, "Date"
or "POSIXct"
. Otherwise
there needs to be an as
method (from package methods)
for conversion from "character"
to the specified formal
class.
Note that colClasses
is specified per column (not per
variable) and so includes the column of row names (if any).
TRUE
then the names of the
variables in the data frame are checked to ensure that they are
syntactically valid variable names. If necessary they are adjusted
(by make.names
) so that they are, and also to ensure
that there are no duplicates.TRUE
blank lines in the
input are ignored.transpose = TRUE
to be read correctly.file
, the R Data Import/Export
Manual and Note.data.frame
) containing a representation of
the data in the file. Empty input is an error unless col.names
is specified, when a 0-row data frame is returned: similarly giving
just a header line if header = TRUE
results in a 0-row data frame.
The term is likely to lead to confusion: Windows will have a Windows Data Interchange Format (DIF) data format as part of its WinFX system, which may or may not be compatible.
scan
, type.convert
,
read.fwf
for reading fixed width
formatted input;
read.table
;
data.frame
.
## read.DIF() may need transpose = TRUE for a file exported from Excel
udir <- system.file("misc", package = "utils")
dd <- read.DIF(file.path(udir, "exDIF.dif"), header = TRUE, transpose = TRUE)
dc <- read.csv(file.path(udir, "exDIF.csv"), header = TRUE)
stopifnot(identical(dd, dc), dim(dd) == c(4,2))
Run the code above in your browser using DataLab