[R] Data Frame as Hash Table

Alan Lue alan.lue at gmail.com
Sun May 30 10:03:01 CEST 2010


I'm interested in using a data frame as if it were a hash table.  For
instance if I had the following,

> (d <- data.frame(key=seq(0.5, 3, 0.5), value=rnorm(6)))
  key        value
1 0.5 -1.118665122
2 1.0  0.465122921
3 1.5 -0.529239211
4 2.0 -0.147324638
5 2.5 -1.531503795
6 3.0 -0.002720434

Then I'd like to be able to quickly retrieve the "value" of "key" 1.5
to get -0.53.  How would one go about doing this?

Yours,
Alan Lue



More information about the R-help mailing list