GULATI, BRIJESH (Global Markets FF&O NY)
2010-Mar-08 13:15 UTC
[R] Data.frame issue (pls help)
Hi: I want to obtain a particular value from a data.frame. Following is my dataframe:> QuotesBID ASK Name CT2 GOVT 99.92969 99.9375 CT2 TUM0 COMDTY 108.53125 108.5469 TUM0 CT5 GOVT 100.10156 100.1094 GT5 FVM0 COMDTY 115.56250 115.5703 FVM0 TYM0 COMDTY 116.93750 116.9531 TYM0 If I try to run: QuoteTUM0BID = Quotes[Quotes$Name %in% "TUM0", "BID"] and print QuoteTUM0BID, I get 108.5312, instead of 108.53125 as an answer. Please let me know why is it ignoring the last digit. Additional Information. If I run QuoteBID = Quotes[, "BID"], I get the whole array in which TUM0 BID is 108.53125 (a correct number). Thanks in advance... Rgds, Brijesh -------------------------------------------------------------------------- This message w/attachments (message) may be privileged, ...{{dropped:30}}
Hi, I cannot really test since your dataframe is completely distorted, but what happens if you try: format(QuoteBID, nsmall=5)? I think it's just a matter of printing, which uses the number of digits from options(digits=). See: ?options, ?format, etc. But I'm not an expert and cannot really test for this. HTH Ivan Le 3/8/2010 14:15, GULATI, BRIJESH (Global Markets FF&O NY) a ?crit :> Hi: > I want to obtain a particular value from a data.frame. Following is my > dataframe: > > >> Quotes >> > BID ASK > Name > CT2 GOVT 99.92969 99.9375 CT2 > TUM0 COMDTY 108.53125 108.5469 TUM0 > CT5 GOVT 100.10156 100.1094 GT5 > FVM0 COMDTY 115.56250 115.5703 FVM0 > TYM0 COMDTY 116.93750 116.9531 TYM0 > > If I try to run: QuoteTUM0BID = Quotes[Quotes$Name %in% "TUM0", "BID"] > and print QuoteTUM0BID, I get 108.5312, instead of 108.53125 as an > answer. Please let me know why is it ignoring the last digit. > > > Additional Information. > If I run QuoteBID = Quotes[, "BID"], I get the whole array in which TUM0 > BID is 108.53125 (a correct number). > > > Thanks in advance... > Rgds, > Brijesh > > > > -------------------------------------------------------------------------- > This message w/attachments (message) may be privileged, ...{{dropped:30}} > > ______________________________________________ > 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. > >-- Ivan CALANDRA PhD Student University of Hamburg Biozentrum Grindel und Zoologisches Museum Abt. S?ugetiere Martin-Luther-King-Platz 3 D-20146 Hamburg, GERMANY +49(0)40 42838 6231 ivan.calandra at uni-hamburg.de ********** http://www.for771.uni-bonn.de http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php
GULATI, BRIJESH (Global Markets FF&O NY)
2010-Mar-10 21:31 UTC
[R] Data.frame Question (add constant to a row)
> Hi: > I want to add a constant to an existing col of the data.frame. I > have the following dataset: > > > structure(list(x = c(1, 1, 1, 1, 1), y = c(1, 1, 1, 1, 1)), .Names > c("x", > "y"), row.names = c(NA, 5L), class = "data.frame") > > > I want to add a constant to col 1 and col 2 to get the following > data.frame > > structure(list(x = c(2, 2, 2, 2, 2), y = c(3, 3, 3, 3, 3)), .Names > c("x", > "y"), row.names = c(NA, 5L), class = "data.frame") > > > Thanks, > Brijesh-------------------------------------------------------------------------- This message w/attachments (message) may be privileged, ...{{dropped:30}}