On Jul 5, 2011, at 2:10 PM, Sam Steingold wrote:

* David Winsemius <qjvafrz...@pbzpnfg.arg> [2011-07-05 13:21:57 -0400]:
On Jul 5, 2011, at 12:53 PM, Sam Steingold wrote:
I am confused by the way the indexing works.
Actually I suspect you may be confused by how factors work. See below.

probably both :-(

being a lisper, I thought about factors as lisp symbols (and thus
thought that they would be accepted everywhere strings are).

Have you considered:

ysmd.table[ as.character( ysmd$X.stock[[100]])  ]

It appears that ysmd$X.stock[[100]] is a factor, and if so, you probably
want the character value that its numeric representation points to.

indeed:

as.character(ysmd$X.stock[[100]])
[1] "FLO"

however,

ysmd.table[as.character(ysmd$X.stock[[100]])]
<hash> containing 0 key-value pair(s).
 NA : NULL

so, as.character is not the answer.

My error. Note the difference in indexing functions. "[" is not "[["


ysmd.table[["FLO"]]
X.stock market.cap X52.week.low X52.week.high X3.month.average.daily.volume 100 FLO 2.984e+09 15.3133 22.37 1021580
   X50.day.moving.average.price
100                      21.3769

So you are here demonstrating that you should be using "[["


This is, of course, guesswork because you have not disclosed what
package hash` comes from, so I do not have the benefit of looking at
its help page.

I just did this:

library(hash);
hash-2.0.1 provided by Open Data.


--

David Winsemius, MD
West Hartford, CT

______________________________________________
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