powered by
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, …)
a string
logical: drop empty first and last element
logical
NULL or character
logical: trim whitespace?
named arguments to be passed to read.table
read.table
a vector or, if sep is specified, a data.frame
sep
data.frame
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.
here
type.convert
s
If sep is specified, the input s is fed to read.table. Additional arguments may be passed through ….
http://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)
# NOT RUN { ## numbers here(" 1 2 3 4 ") ## character here(" Al Bob Carl David ") ## data frame here(" letter, number x, 1 y, 2 z, 3", sep = ",") # }
Run the code above in your browser using DataLab