read.file | R Documentation |
A wrapper around various file reading functions.
read.file(
file,
header = T,
na.strings = "NA",
comment.char = NULL,
filetype = c("default", "csv", "txt", "tsv", "fw", "rdata"),
stringsAsFactors = FALSE,
readr = FALSE,
package = NULL,
...
)
file |
character:
The name of the file which the data are to be read from.
This may also be a complete URL or a path to a compressed file.
If it does not contain an absolute path, the file name is
relative to the current working directory,
|
header |
logical;
For |
na.strings |
character: strings that indicate missing data. |
comment.char |
character: a character vector of length one containing a single character or an empty string. Use "" to turn off the interpretation of comments altogether. |
filetype |
one of |
stringsAsFactors |
a logical indicating whether strings should be converted to factors.
This has no affect when using |
readr |
a logical indicating whether functions from the |
package |
if specified, files will be searched for among the documentation files provided by the package. |
... |
additional arguments passed on to
|
Unless filetype
is specified,
read.file
uses the (case insensitive) file extension to determine how to read
data from the file. If file
ends in .rda
or .rdata
, then
load()
is used to load the file. If file
ends in .csv
, then readr::read_csv()
or read.csv()
is used.
Otherwise, read.table()
is used.
A data frame, unless file
unless filetype
is "rdata"
,
in which case arbitrary objects may be loaded and a character vector
holding the names of the loaded objects is returned invisibly.
read.csv()
, read.table()
,
readr::read_table()
, readr::read_csv()
,
load()
.
## Not run:
Dome <- read.file("http://www.mosaic-web.org/go/datasets/Dome.csv")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.