[R] Remove [1] ... from output

Gregor Gorjanc gregor.gorjanc at gmail.com
Wed Mar 29 01:08:15 CEST 2006


Thank you Adelchi and Ales!

Adelchi Azzalini wrote:
> On Tue, 28 Mar 2006 13:21:59 +0200, Gregor Gorjanc wrote:
> 
> GG> Hello!
> GG> 
> GG> I am writing some numbers and character vectors to an ascii file
> GG> and would like to get rid of [1] ... as shown bellow (a dummy
> GG> example)
> GG> 
> GG> R> runif(20)
> GG>  [1] 0.653574 0.164053 0.036031 0.127208 0.134274 0.103252
> GG>  0.506480 0.547759 [9] 0.912421 0.584382 0.987208 0.996846
> GG>  0.666760 0.053637 0.327590 0.370737
> GG> [17] 0.505706 0.412316 0.887421 0.812151
> GG> 
> GG> I have managed to work up to remove quotes and all [*] except [1]
> GG> as shown bellow.
> GG> 
> GG> R> print(paste(runif(20), collapse = " "), quote = FALSE)
> GG> [1] 0.790620362851769 0.45603066496551 0.563822037540376
> GG> 0.812907998682931 0.726162418723106 0.37031230609864
> GG> 0.681147597497329 0.29929908295162 0.209858040558174
> GG> 0.304300333140418 0.105796672869474 0.743657597573474
> GG> 0.409294542623684 0.825012607965618 0.282235795632005
> GG> 0.21159387845546 0.620056127430871 0.337449935730547
> GG> 0.754527133889496 0.280175548279658
> GG> 
> GG> Any hints how to solve my task?
> GG> 
> 
> what about 
>   cat(format(runif(20)))
> ?
> 
> you can improve it a bit with
> 
>  cat(format(runif(20)),"\n")

-- 
Lep pozdrav / With regards,
    Gregor Gorjanc

----------------------------------------------------------------------
University of Ljubljana     PhD student
Biotechnical Faculty
Zootechnical Department     URI: http://www.bfro.uni-lj.si/MR/ggorjan
Groblje 3                   mail: gregor.gorjanc <at> bfro.uni-lj.si

SI-1230 Domzale             tel: +386 (0)1 72 17 861
Slovenia, Europe            fax: +386 (0)1 72 17 888

----------------------------------------------------------------------
"One must learn by doing the thing; for though you think you know it,
 you have no certainty until you try." Sophocles ~ 450 B.C.




More information about the R-help mailing list