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
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.file
The term is likely to lead to confusion: Windows will have a
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 DataCamp Workspace