My apologies, I know that this is not a new problem, but I'm not sure how
to find the answer

I want to recursively loop over an object and trim trailing white space.
When I use this function on a list of data.frame I get output like this:
[1] "c(\"   many spaces   \", \"   many spaces   \")" "c(\"   many spaces
\", \"   many spaces   \")"

What should I do to recombine the results?
If anyone has a good way to search for this type of question, that would be
appreciated.  I tried rseek.org with "recursive", but after wading though
all the rpart references I didn't find something that seemed to help with
this problem.

Thank you very much.


trim <- function(x) {
    if(length(x)>1) sapply(x[1], trim)
    gsub("^[[:space:]]+|[[:space:]]+$", "", x)
}

tempobj = '   many spaces   '
tempvec = c(tempobj, tempobj)
templist = list(tempvec, tempvec)
tempdf = data.frame(x = tempvec, y = tempvec)

trim(tempobj)
trim(tempvec)
trim(templist)
trim(tempdf)





Thank you,
   Gene Leynes
_____________________________________________
*Data Scientist*
*Mobile: 312-498-7702
**http://www.linkedin.com/in/geneleynes
*
<http://goog_598053156>*http://geneorama.com/ <http://geneorama.com/%20>*

	[[alternative HTML version deleted]]

