here | R Documentation |
Read lines and convert into appropriate vector or data frame.
here(s, drop = TRUE, guess.type = TRUE, sep = NULL, header = TRUE,
stringsAsFactors = FALSE, trim = TRUE, ...)
s |
a string |
drop |
logical: drop empty first and last element |
guess.type |
logical |
sep |
NULL or character |
header |
logical |
stringsAsFactors |
logical |
trim |
logical: trim whitespace? |
... |
named arguments to be passed to |
Experimental. (Notably, the function's name may change.)
The function reads a (typically multi-line) string and treats each
line as one element of a vector or, if sep is specified, a
data.frame
.
If sep
is not specified, here
calls
type.convert
on the input s
.
If sep
is specified, the input s
is fed to
read.table
. Additional arguments may be passed
through ....
a vector or, if sep
is specified, a data.frame
Enrico Schumann
https://rosettacode.org/wiki/Here_document
(note that R supports multi-line strings, so in a way it has built-in support for here documents as defined on that website)
type.convert
## numbers
here("
1
2
3
4
")
## character
here("
Al
Bob
Carl
David
")
## data frame
here("
letter, number
x, 1
y, 2
z, 3",
sep = ",")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.