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

From: Stefano Calza <stecalza_at_tiscali.it>
Date: Wed 26 Oct 2005 - 00:42:27 EST

What about

xx <- c("AIR ", "ABCB ", "ABXA ", "ACMR ", "ADCT ", "ADEX "," AAA")

xx=gsub("[[:blank:]]","",xx)

Stefano

On Tue, Oct 25, 2005 at 03:14:39PM +0200, Dimitris Rizopoulos wrote:
<Dimitris>one way is to use strsplit(), i.e.,
<Dimitris>
<Dimitris>xx <- c("AIR ", "ABCB ", "ABXA ", "ACMR ", "ADCT ", "ADEX ")
<Dimitris>
<Dimitris>Best,
<Dimitris>Dimitris
<Dimitris>
<Dimitris>----
<Dimitris>Dimitris Rizopoulos
<Dimitris>Ph.D. Student
<Dimitris>Biostatistical Centre
<Dimitris>School of Public Health
<Dimitris>Catholic University of Leuven
<Dimitris>
<Dimitris>Address: Kapucijnenvoer 35, Leuven, Belgium
<Dimitris>Tel: +32/(0)16/336899
<Dimitris>Fax: +32/(0)16/337015
<Dimitris>Web: http://www.med.kuleuven.be/biostat/
<Dimitris> http://www.student.kuleuven.be/~m0390867/dimitris.htm
<Dimitris>
<Dimitris>
<Dimitris>----- Original Message -----
<Dimitris>From: "roger bos" <roger.bos@gmail.com>
<Dimitris>To: "(r-help@stat.math.ethz.ch.)" <R-help@stat.math.ethz.ch>
<Dimitris>Sent: Tuesday, October 25, 2005 2:51 PM
<Dimitris>Subject: [R] Can anyone please tell me how to strip the white spaces
<Dimitris>from acharacter vector?
<Dimitris>
<Dimitris>
<Dimitris>> for example:
<Dimitris>>> a$tic[1:10]
<Dimitris>> [1] "AIR " "ABCB " "ABXA " "ACMR " "ADCT " "ADEX "
<Dimitris>> [7] "ABM " "AFCE " "AG " "ATG "
<Dimitris>> Can anyone please tell me how to strip the white spaces from a$tic?
<Dimitris>> Thanks,
<Dimitris>> Roger
<Dimitris>>
<Dimitris>> [[alternative HTML version deleted]]
<Dimitris>>
<Dimitris>> ______________________________________________
<Dimitris>> R-help@stat.math.ethz.ch mailing list
<Dimitris>> https://stat.ethz.ch/mailman/listinfo/r-help
<Dimitris>> PLEASE do read the posting guide!
<Dimitris>> http://www.R-project.org/posting-guide.html
<Dimitris>>
<Dimitris>
<Dimitris>
<Dimitris>Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
<Dimitris>
<Dimitris>______________________________________________
<Dimitris>R-help@stat.math.ethz.ch mailing list
<Dimitris>https://stat.ethz.ch/mailman/listinfo/r-help
<Dimitris>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:52:44 2005

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