On 04/09/2013 22:56, Noah Silverman wrote:
Hi,
Working with R, I often want to copy and paste some values somewhere else.
(Its not worth saving a CSV file for a dozen or so entries.) Or, I may want to
copy all the names of an object into some code.
R, rather nicely, wraps output with an index number on the left side.
For example:
[1] -1.07781972 -1.12157840 1.79303276 1.53313388 -1.30854455 0.45641730
0.23866722 -1.96265084
[9] -1.90779578 -0.68418936 -2.04910282 0.12008358 -1.71072687 -0.36707605
-0.36939204 -2.02799948
[17] 0.36466562 -1.34204214 -0.45100125 -0.60483154 0.42208268 -0.89535576
-1.09398009 -2.07257728
[25] -0.04615273 -0.23659570 0.27232736 1.28432538 -2.17042948 -0.45364579
1.52957528 0.39838320
[33] 0.64923323 -1.01651051 -0.36287974 -0.73787761 0.48088199 -1.19539814
-0.80079095 -1.02507331
While this is great to read on screen, it is a pain to have to edit out all the
index numbers.
Is there a simple way to just back the values, or even a comma separated list
of the values?
There are many. Here I usually use write(x, ""). The file = "" trick
works in many other functions.
Using dput() and removing c( and ) is also often useful when comma
separation is needed.
--
Brian D. Ripley, rip...@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
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.