[R] strip white in character strings

Roland Rau roland.rproject at gmail.com
Wed May 14 18:06:39 CEST 2008


Dear all,

I have several datasets and I want to generate pdf plots from them.
I also want to generate automatically the names of the files. They are 
country-specific and the element mycurrentdata[1,1] contains this 
information.

So what I do is something like this:
pdf(file=paste(mycurrentdata[1,1], ".pdf", sep=""), width=...etc)

The only problem I have is that some of the country names contain white 
space (e.g., "United Kingdom"). This is no problem for generating the 
pdf plots but it may become problematic during further processing (e.g. 
incl. the plots in LaTeX documents).

Is there an easy function to strip white space out of character strings 
(similar to the strip.white=TRUE option in read.table/scan)?

I'd appreciate any kind of help and I hope I did not miss anything 
completely obvious.

Thanks,
Roland



More information about the R-help mailing list