[R] How to create "special" (source) file
Prof Brian Ripley
ripley at stats.ox.ac.uk
Mon Jan 2 14:00:52 CET 2006
On Mon, 2 Jan 2006, Eduardo Esteves wrote:
> Dear All,
>
> I'm a Marine Biologist using R (in a most informal and applied way) for
> a couple of years. Actually, I've been using R to analyse the results
> supporting my thesis. I would like to put together (in the same file)
> the data (.txt files) and the scripts files (.R files) for each chapter.
> How can I do this?
With some difficulty. What I suggest would be a better idea is to read
in your data files and dump() then, then edit the dumps into the scripts.
However, you can do things like
## preamble
galaxies <- scan()
9172 9350 9483 9558 9775 10227 10406 16084 16170 18419 18552 18600
18927 19052 19070 19330 19343 19349 19440 19473 19529 19541 19547 19663
19846 19856 19863 19914 19918 19973 19989 20166 20175 20179 20196 20215
20221 20415 20629 20795 20821 20846 20875 20986 21137 21492 21701 21814
21921 21960 22185 22209 22242 22249 22314 22374 22495 22746 22747 22888
22914 23206 23241 23263 23484 23538 23542 23666 23706 23711 24129 24285
24289 24366 24717 24990 25633 26690 26995 32065 32789 34279
hist(galaxies)
but you can't use source() on such a script.
Perhaps an even better idea is to put together a small package which has
your data in mypkg/data and the scripts in mypkg/inst/scripts.
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list