Friends

I have a data frame, df that I want to extract some rows from

Here is a sample of the data

> head(df)
     TDate Expiry Underlie Strike CSettle PSettle Futures   ExDate
TTE
1 20080102 200801   200803  0.840  0.0000       0  0.9207 20080104
0.005479452
2 20080102 200801   200803  0.850  0.0000       0  0.9207 20080104
0.005479452
    Rate      Disc
1 0.0457 0.9997496
2 0.0457 0.9997496

I want all rows where TTE is equal to 0.024657534

> head(summary(factor(df[,"TTE"])), n=1)
0.024657534
        602

Using...

head(df["TTE">=0.02])
I get

> head(df["TTE">=0.02])
     TDate Expiry Underlie Strike CSettle PSettle Futures   ExDate
TTE
1 20080102 200801   200803  0.840  0.0000       0  0.9207 20080104
0.005479452
2 20080102 200801   200803  0.850  0.0000       0  0.9207 20080104
0.005479452
    Rate      Disc
1 0.0457 0.9997496
2 0.0457 0.9997496

Which is obviously not working.  How can I make it work?

I can do
> tte.CSettle <- df[c("TTE", "CSettle")]
> tte.1 <- tte.CSettle[tte.CSettle<0.03,]
> tte.2 <- tte.1[tte.1>0.02,]
> head(tte.2)
           TTE CSettle
582 0.02465753  0.0000
583 0.02465753  0.0000
> tail(tte.2)
         TTE CSettle
NA.72617  NA      NA
NA.72618  NA      NA
>

So I have introduced a lot of NAs that were not there before.

I think I have done this before I just cannot remember how.  The
Extract.data.frame help page does not tell me how.

cheers
Worik
worik.stan...@gmail.com

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to