I would like to apply grep() in R, but I am not really good in lapply(). I understand that lapply is able to take a list, apply function to each members and output a list. For instance, let x
be a list consists of 2 members.
> x<-strsplit(docs$Text," ")
>
> x
[[1]]
[1] "I" "lovehttp" "my" "mum." "I" "love"
[7] "my" "dad." "I" "love" "my" "brothers."
[[2]]
[1] "I" "live" "in" "Eastcoast" "now." "Job.I"
[7] "used" "to" "live" "in" "WestCoast."
I would like to apply grep() function to remove words consisting of http. So, I would apply:
> lapply(x,grep(pattern="http",invert=TRUE, value=TRUE))
But it does not work and it says
Error in grep(pattern = "http", invert = TRUE, value = TRUE) :
argument "x" is missing, with no default
So, I tried
> lapply(x,grep(pattern="http",invert=TRUE, value=TRUE,x))
But it says
Error in match.fun(FUN) :
'grep(pattern = "http", invert = TRUE, value = TRUE, x)' is not a
function, character or symbol
A help please, and thanks!