[R] Can anyone please tell me how to strip the white spaces from acharacter

Francisco J. Zagmutt gerifalte28 at hotmail.com
Tue Oct 25 22:34:29 CEST 2005


I addition to all the many good options presented you can also use 
trimWhiteSpace{limma} which is just a higher level call to sub()

x=scan("clipboard", what="character")
Read 6 items
x
[1] "AIR "  "ABCB " "ABXA " "ACMR " "ADCT " "ADEX "

trimWhiteSpace(x)
[1] "AIR"  "ABCB" "ABXA" "ACMR" "ADCT" "ADEX"


Cheers

Francisco


>From: roger bos <roger.bos at gmail.com>
>To: "(r-help at stat.math.ethz.ch.)" <R-help at stat.math.ethz.ch>
>Subject: [R] Can anyone please tell me how to strip the white spaces from 
>acharacter vector?
>Date: Tue, 25 Oct 2005 08:51:48 -0400
>
>for example:
> > a$tic[1:10]
>[1] "AIR " "ABCB " "ABXA " "ACMR " "ADCT " "ADEX "
>[7] "ABM " "AFCE " "AG " "ATG "
>  Can anyone please tell me how to strip the white spaces from a$tic?
>  Thanks,
>  Roger
>
>	[[alternative HTML version deleted]]
>
>______________________________________________
>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




More information about the R-help mailing list