[R] Programcode and data in the same textfile
(Ted Harding)
Ted.Harding at nessie.mcc.ac.uk
Thu Jun 12 16:21:28 CEST 2003
On 12-Jun-03 Ted Harding wrote:
> i.e. the "here document" style of redirection that has been a part
> of Unix since approximately forever (if you take the origin of time
> as 01/01/70 00:00). Then the above data could be read in from within
> the source file by
>
> X<-read.table(header=TRUE,file="<< EOT")
> Sex Respons
> Male 1
> Male 2
> Female 3
> Female 4
> EOT
A follow-up (should have thought to mention it last time).
Users of Unix troff / GNU groff may be familiar with the "inline data
input" used by 'pic', where the form is:
.PS
<pic commands>
copy thru <macroname> until "EOT"
1.1 1.2 1.3
2.1 2.2 2.3
...
9.1 9.2 9.3
EOT
<pic commands>
.PE
This is exactly the same idea, and the more I think about it the more
attractive it seems to have this facility available in R. In fact,
the most useful implementation would be that wherever file="..."
could be used in a command to read from a text file, the form
file="<< MARKER" could be used to read in from the following lines of
the file.
Ted.
--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk>
Fax-to-email: +44 (0)870 167 1972
Date: 12-Jun-03 Time: 15:20:53
------------------------------ XFMail ------------------------------
More information about the R-help
mailing list