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? -- 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.
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
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/
[Gregor Gorjanc]>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?You may use "cat" instead of "print". No need to "paste" then. -- Fran?ois Pinard http://pinard.progiciels-bpi.ca
Use "cat" cat(runif(20)) see ?cat for additional options, for example to brake the output into several lines. Best regards, Ales Gregor Gorjanc pravi:> 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? > >
On Tue, Mar 28, 2006 at 01:21:59PM +0200, Gregor Gorjanc wrote:> > 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 > > Any hints how to solve my task?The indexes are generated by the print method for the vector. Use cat instead:> cat(runif(20))0.01053970 0.7196873 0.08709377 0.2059949 0.9583586 0.7059125 0.8179168 0.2345666 0.4157858 0.0538792 0.4140722 0.5700817 0.7087922 0.4012365 0.6587029 0.2803821 0.7353465 0.4457628 0.09914006 0.8109087 cu Philipp -- Dr. Philipp Pagel Tel. +49-8161-71 2131 Dept. of Genome Oriented Bioinformatics Fax. +49-8161-71 2186 Technical University of Munich Science Center Weihenstephan 85350 Freising, Germany and Institute for Bioinformatics / MIPS Tel. +49-89-3187 3675 GSF - National Research Center Fax. +49-89-3187 3585 for Environment and Health Ingolst?dter Landstrasse 1 85764 Neuherberg, Germany http://mips.gsf.de/staff/pagel
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.