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

Benjamin Dickgiesser dickgiesser at gmail.com
Tue Jan 9 18:06:25 CET 2007


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 at 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
>



More information about the R-help mailing list