Re: [R] Can anyone please tell me how to strip the white spaces from a character vector?

From: Uwe Ligges <ligges_at_statistik.uni-dortmund.de>
Date: Tue 25 Oct 2005 - 23:14:17 EST

roger bos wrote:

> 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?

Not beeing an expert for regular expressions, I'd try

    sub(" *$", "", sub("^ *", "", a$tic)) to strip from beginnings and ends but there may be far better approches. In order to remove *all* blanks, try

    gsub(" ", "", a$tic)

Uwe Ligges

> Thanks,
> Roger
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@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



R-help@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 Received on Wed Oct 26 00:06:32 2005

This archive was generated by hypermail 2.1.8 : Wed 26 Oct 2005 - 03:12:31 EST