[R] How to remove white spaces

Bos, Roger roger.bos at us.rothschild.com
Sat Aug 16 03:22:58 CEST 2008


All,

I am storing a string of email addresses in a table and when I retrieve
them using a RODBC statement such as:

test = sqlQuery(xf, "select specialist from
roger_sector_specialist")$specialist

'test' is of mode list and includes a bunch of white space.  As a
work-around I convert 'test' to a character string, split it based on a
white space, then take the first element:

test = strsplit(as.character(test), " ")
emaillist = test[[1]][1]
   
But I am sure there is a better way.  I did help.search("trim white
space") and R didn't return anything, which I found strange.  Any
advice?

Thanks,

Roger

********************************************************************** * 
This message is for the named person's use only. It may 
contain confidential, proprietary or legally privileged 
information. No right to confidential or privileged treatment 
of this message is waived or lost by any error in 
transmission. If you have received this message in error, 
please immediately notify the sender by e-mail, 
delete the message and all copies from your system and destroy 
any hard copies. You must not, directly or indirectly, use, 
disclose, distribute, print or copy any part of this message 
if you are not the intended recipient. 



More information about the R-help mailing list