Hi All, I have a vector of length 48, something like: 0 0 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 I would like to print (reformat) this vector as: 001100000000001111111111111111111111111111111111 by simply removing the spaces between them. I have been trying with many option but not able to do this task. I would greatly appreciate your suggestion on fixing this simple task. Thanks in advance. Kind regards, Ezhil ____________________________________________________________________________________ Bored stiff? Loosen up...
A Ezhil wrote:> Hi All, > > I have a vector of length 48, something like: > 0 0 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 > 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 > > I would like to print (reformat) this vector as: > 001100000000001111111111111111111111111111111111 > > by simply removing the spaces between them. I have > been trying with many option but not able to do this > task. > I would greatly appreciate your suggestion on fixing > this simple task.X <- rbinom(n=48, size=1, prob=.3) paste(X, collapse="") [1] "101111000001001000000010000000110100100101000011" print(paste(X, collapse=""), quote=FALSE) [1] 101111000001001000000010000000110100100101000011> Thanks in advance. > > Kind regards, > Ezhil > > > > > ____________________________________________________________________________________ > Bored stiff? Loosen up... > > ______________________________________________ > R-help at stat.math.ethz.ch 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.-- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894
On Fri, 2007-06-08 at 06:13 -0700, A Ezhil wrote:> Hi All, > > I have a vector of length 48, something like: > 0 0 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 > 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 > > I would like to print (reformat) this vector as: > 001100000000001111111111111111111111111111111111 > > by simply removing the spaces between them. I have > been trying with many option but not able to do this > task. > I would greatly appreciate your suggestion on fixing > this simple task. > > Thanks in advance.> dat <- scan()1: 0 0 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 28: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 49: Read 48 items> dat[1] 0 0 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1[39] 1 1 1 1 1 1 1 1 1 1> print(dat, print.gap = 0)[1]001100000000001111111111111111111111111111111111 Is that what you want? It is just altering how the data are printed. You still get the [1] at the start though. G -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%