[R] What is the best way to delete strings in a string list that that match certain pattern?

Charles C. Berry cberry at tajo.ucsd.edu
Fri Nov 6 17:22:22 CET 2009


On Fri, 6 Nov 2009, Peng Yu wrote:

> On Fri, Nov 6, 2009 at 3:05 AM, Diez B. Roggisch <deets at nospam.web.de> wrote:
>> Peng Yu schrieb:
>>>
>>> Suppose I have a list of strings, A. I want to compute the list (call
>>> it B) of strings that are elements of A but doesn't match a regex. I
>>> could use a for loop to do so. In a functional language, there is way
>>> to do so without using the for loop.
>>
>> Nonsense. For processing over each element, you have to loop over them,
>> either with or without growing a call-stack at the same time.
>>
>> FP languages can optimize away the stack-frame-growth (tail recursion) - but
>> this isn't reducing complexity in any way.
>>
>> So use a loop, either directly, or using a list-comprehension.
>
> What is a list-comprehension?


 	http://lmgtfy.com/?q=list+comprehension


>
> ______________________________________________
> 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.
>

Charles C. Berry                            (858) 534-2098
                                             Dept of Family/Preventive Medicine
E mailto:cberry at tajo.ucsd.edu	            UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901




More information about the R-help mailing list