read.tsv | R Documentation |
This is a convenience wrapper around read.table
for reading
tab delimited files. Parsing is the same as with
read.table
, except the separator is "\t"
, headers are by
default assumed to be present, and strings are automatically read in as
strings. You can change these defaults or any other read.table
parameter as they are passed through via ...
, but you should probably
use the actual read.table
function if you change sep
.
read.tsv(file, header = TRUE, sep = "\t", stringsAsFactors = FALSE, ...)
file |
The path to the tab-delimited file. |
header |
Default is |
sep |
The separator defaults to |
stringsAsFactors |
Set |
... |
Passes other parameters through to |
A data frame corresponding to the *.tsv file as specified by the
parameters above and the defaults from read.table
. See
read.table
for details.
It is a fatal error if the file does not exist, can not be read, or is empty.
read.table
# Create a temp.tsv file to read
tsvFile <- makeTempFile( ext=".tsv", lines= c(
"name\tval\tok",
"A\t1\tTRUE",
"B\t2\tFALSE"
))
read.tsv( tsvFile )
#> name val ok
#> 1 A 1 TRUE
#> 2 B 2 FALSE
# A temp.tsv file without a header
tsvFile <- makeTempFile( ext=".tsv", lines= c(
"A\t1\tTRUE",
"B\t2\tFALSE"
))
read.tsv( tsvFile )
#> V1 V2 V3
#> 1 A 1 TRUE
#> 2 B 2 FALSE
# Pass-through setting column names.
tsvFile <- makeTempFile( ext=".tsv", lines= c(
"A\t1\tTRUE",
"B\t2\tFALSE"
))
read.tsv( tsvFile, header=FALSE, col.names= c( "name", "val", "ok" ))
#> name val ok
#> 1 A 1 TRUE
#> 2 B 2 FALSE
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.