Re: [R] Formating the data

From: Gavin Simpson <gavin.simpson_at_ucl.ac.uk>
Date: Fri, 08 Jun 2007 14:49:01 +0100

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
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

______________________________________________
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.
Received on Fri 08 Jun 2007 - 14:07:52 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 08 Jun 2007 - 14:31:34 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.