[R] Console Output Formatting
arun
smartpink111 at yahoo.com
Thu Sep 5 00:24:02 CEST 2013
Hi,
You could use ?cat()
For ex:
vec1<-1:100
cat(vec1)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100>
cat(vec1,sep=",")
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100>
#or
write(vec1,"",sep=",")
1,2,3,4,5
6,7,8,9,10
11,12,13,14,15
16,17,18,19,20
21,22,23,24,25
26,27,28,29,30
31,32,33,34,35
36,37,38,39,40
41,42,43,44,45
46,47,48,49,50
51,52,53,54,55
56,57,58,59,60
61,62,63,64,65
66,67,68,69,70
71,72,73,74,75
76,77,78,79,80
81,82,83,84,85
86,87,88,89,90
91,92,93,94,95
96,97,98,99,100
A.K.
----- Original Message -----
From: Noah Silverman <noahsilverman at ucla.edu>
To: R help <r-help at r-project.org>
Cc:
Sent: Wednesday, September 4, 2013 5:56 PM
Subject: [R] Console Output Formatting
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?
Thanks!
--
Noah Silverman, M.S., C.Phil
UCLA Department of Statistics
8117 Math Sciences Building
Los Angeles, CA 90095
______________________________________________
R-help at 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.
More information about the R-help
mailing list