Re: [R] Logical operations or selecting data from data.frames

From: Benjamin Dickgiesser <dickgiesser_at_gmail.com>
Date: Tue 09 Jan 2007 - 19:00:12 GMT

Thx for the help, sorry I am just used to use && from php and simply assumed it would work identically.

On 1/9/07, Patrick Burns <pburns@pburns.seanet.com> wrote:
> S Poetry (and other documentation) will tell you
> the difference between '&&' and '&'.
>
> Patrick Burns
> patrick@burns-stat.com
> +44 (0)20 8525 0696
> http://www.burns-stat.com
> (home of S Poetry and "A Guide for the Unwilling S User")
>
> Benjamin Dickgiesser wrote:
>
> >I suppose this doesn't work for the same reason as

> >sdata$VaR < sdata$DdtdAbs && sdata$DdtdDuration >= 1
> >
> >does only return FALSE and not a vector of TRUE and FALSE as

> >
> >sdata$VaR < sdata$DdtdAbs
> >
> >would return.
> >
> >Is there a ways around this?
> >Benjamin
> >
> >On 1/9/07, Benjamin Dickgiesser <dickgiesser@gmail.com> wrote:
> >
> >
> >>Hi all,
> >>
> >>why doesn't something like this does not work?
> >>
> >>speedy <-
> >> (sdata$VaR < sdata$DdtdAbs) && sdata$DdtdDuration >= qpois(pct,lambda) &&
> >> sdata$Ddtd > MinDD
> >>
> >>or sdata$Ddtd[sdata$Ddtd > 0 && sdata$VaR < sdata$DdtdAbs]
> >>
> >>sdata looks like this:
> >>
> >> dataId date value Ddtd VaR DdtdAbs DdtdDuration
> >>18948 79637 2004-07-27 10085.10 NA NA 0.00 0
> >>18949 79638 2004-07-28 10117.10 NA NA 0.00 0
> >>18950 79639 2004-07-29 10129.20 NA NA 0.00 0
> >>18951 79640 2004-07-30 10139.70 NA NA 0.00 0
> >>18952 79641 2004-08-02 10179.20 NA NA 0.00 0
> >>18953 79642 2004-08-03 10120.20 0.579613329 336.060090 59.00 1
> >>18954 79643 2004-08-04 10126.50 NA NA 0.00 0
> >>18955 79644 2004-08-05 9963.03 1.614279366 334.306978 163.47 1
> >>18956 79645 2004-08-06 9815.33 3.072828717 386.173057 311.17 2
> >>18957 79646 2004-08-09 9814.66 3.079445020 420.167049 311.84 3
> >>18958 79647 2004-08-10 9944.67 NA NA 0.00 0
> >>18959 79648 2004-08-11 9938.32 0.063853300 328.315992 6.35 1
> >>18960 79649 2004-08-12 9814.59 1.308037371 379.182568 130.08 2
> >>
> >>I am trying to select rows from the data.frame which have Ddtd > x,
> >>VaR < DdtdAbs and DdtdDuration > z.
> >>
> >>Thank you,
> >>Benjamin
> >>
> >>
> >>
> >
> >______________________________________________
> >R-help@stat.math.ethz.ch 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.
> >
> >
> >
> >
>



R-help@stat.math.ethz.ch 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. Received on Wed Jan 10 06:06:16 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 09 Jan 2007 - 19:31:46 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.