[R] Odp: Remove space from string

Petr PIKAL petr.pikal at precheza.cz
Fri Jan 13 13:39:31 CET 2012


Hi

> 
> Dear R users,
> 
> I have some trivial query.
> 
> I have a string, I want to remove space from the string.
> 
> For eg.
> 
> Input:
> a <- " Remove space "
> 
> Output required:
> "Removespace"

It seems to be simple. Even myself with very poor knowledge of regexpr can 
suggest solution.

gsub(" ", "", a)

Regards
Petr


> 
> I tried using str_trim but only removes end spaces. library(stringr).
> 
> Regards
> Vikram
> 
>    [[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list