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

Use cat() instead of print:

 > cat(runif(20))
0.7488857 0.7319368 0.2803859 0.3738669 0.5619917 0.3179777 0.2414058 
0.7494183 0.7967387 0.9084999 0.5811184 0.1158764 0.1048582 0.8314966 
0.2892489 0.1403012 0.6296523 0.3318759 0.8797555 0.8332503

There are optional parameters to cat() to insert line breaks (sep="\n"), 
etc.

Duncan Murdoch

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to