[R] Removing numbers from a list

vioravis vioravis at gmail.com
Thu Nov 10 11:29:16 CET 2011


I am using gsub to remove numbers for each element of a list. Code is given
below.

  testList <- list("this contains a number 1000","this does not contain")
  removeNumbers <- function(X)
  {
    gsub("\\d","",X) 
  }
  outputList <- lapply(testList,removeNumbers)

However, when I try to find the number of words in outputList as follows

  outLength <- lapply(strsplit(outputList," "),length)

it throws out the following error:

  Error in strsplit(outputList, " ") : non-character argument


Can someone help me with this? 

Thank you.

Ravi

--
View this message in context: http://r.789695.n4.nabble.com/Removing-numbers-from-a-list-tp4023074p4023074.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list