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

cgb@datanalytics.com cgb at datanalytics.com
Tue Oct 25 15:01:03 CEST 2005


Quoting roger bos <roger.bos at gmail.com>:

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

> a <- c("ab ", "cd", "ef ")
> gsub(" ", "", a)
[1] "ab" "cd" "ef"

Carlos J. Gil Bellosta
http://www.datanalytics.com




More information about the R-help mailing list