[R] subset range selections

Duncan Murdoch murdoch at stats.uwo.ca
Mon Jul 13 16:49:59 CEST 2009


On 7/13/2009 10:21 AM, Mark Knecht wrote:
> Thanks Jim.
> 
> How does one search the help system for info on simple logic like this?

Look in the manuals (the pdf ones), rather than the man pages.  For 
example, expressions like the ones below are in the Introduction to R, 
section 2.4, Logical Vectors.  (The table of contents contains "Logical 
vectors", within "Simple manipulations".)

Duncan Murdoch

> 
> On Mon, Jul 13, 2009 at 6:59 AM, jim holtman<jholtman at gmail.com> wrote:
>> 1)   X <- subset(A, (t < 1000) | (t > 1200))
>> 2)   X <- subset(A, (t > 1000) & (t < 1200))
>>
>> On Mon, Jul 13, 2009 at 9:47 AM, Mark Knecht<markknecht at gmail.com> wrote:
>>> How would I write the two selections each in a single subset command?
>>>
>>> 1) Two non-overlapping time ranges I want to collect together - before
>>> 10AM and after noon. Should be an OR function:
>>>
>>> X = subset(A, t<1000)  + subset(A, t>1200)
>>>
>>> 2) One range between two defined times like after 10AM and before
>>> noon. Should be an AND function:
>>>
>>> X1 = subset(A, t>1000)
>>> X = subset(X1, t<1200)
>>>
>>> Thanks,
>>> Mark
>>>
>>> P.S. - The help system seems very difficult for finding this sort of
>>> information!
>>>
>>> ______________________________________________
>>> 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.
>>>
>>
>>
>>
>> --
>> Jim Holtman
>> Cincinnati, OH
>> +1 513 646 9390
>>
>> What is the problem that you are trying to solve?
>>
> 
> ______________________________________________
> 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