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

Adelchi Azzalini azzalini at stat.unipd.it
Tue Mar 28 15:46:01 CEST 2006


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")




-- 
Adelchi Azzalini  <azzalini at stat.unipd.it>
Dipart.Scienze Statistiche, Università di Padova, Italia
tel. +39 049 8274147,  http://azzalini.stat.unipd.it/




More information about the R-help mailing list