[R] Formating the data

Chuck Cleland ccleland at optonline.net
Fri Jun 8 15:43:19 CEST 2007


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



More information about the R-help mailing list