Description Usage Arguments Details Value Examples
read.so
and read_so
read data copied from R print methods into a
data.frame or tibble, respectively.
1 2 3 4 5 6 7 8 9 |
file |
Character. A path to a file, a connection, or literal data (either a single string or a vector of lines). If unspecified, reads from the clipboard. |
header |
Logical. Does the data include a header row? |
na.strings, na |
Character. Values to convert to |
stringsAsFactors |
Logical. Indicates whether to convert string columns
to factors. Passed along to |
... |
Passed along to |
row_names |
Logical. Indicates whether the input contains a column of
row names. If missing, guesses based on the number of elements in the
header and first row. Row names are removed by |
read.so
is designed to read the print method of a data.frame back into R,
provided there are no unquoted spaces within the printing. read_so
will
read the results of printing a data.frame as well, but will return a tibble.
Its more significant feature is that it will read in the results of printing
a tibble, with or without the "A tibble", type, and additional row and
column metadata lines.
The file
parameter will accept a filepath or connection, but given that
these functions are built for interactive use, they are built to accept a
single string containing the data (distinguished from a filepath by the
presence of a newline) or a vector of lines, as may be generated by
clipr::read_clip()
.
For read.so
a data.frame; for read_so
, a tibble.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | lines.df <- capture.output(head(iris))
lines_tbl <- capture.output(head(tibble::as_tibble(iris)))
read.so(lines.df)
read_so(lines.df)
## Not run:
# Data has extra metadata lines, so normal reading fails:
read.so(lines_tbl)
# ...but can work:
read.so(lines_tbl, comment = '<', skip = 1)
## End(Not run)
# Alternately, use the purpose-built function:
read_so(lines_tbl)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.