Reputation: 11
So trying to use referenceClasses for the first time. I figured out how to create an object, but I want an "array" of objects. I usually use data.frames but you can't put an object in a data frame. trying to use lists, but can't figure it out. Like this:
Stock <- setRefClass("Stock",
fields = list(
symbol = "character",
expArray = "data.frame",
quote = "numeric",
))
validExp <-c("131108","131115","131122","131129","131206","131221","140118","140719","150117")
validStocks <- c("AAPL", "TSLA","GOOG","HLF")
expArray <- data.frame(exp = validExp)
aStock <- Stock(symbol = "GOOG", expArray = expArray, quote=0)
which works fine. But now how to I get an "array" of Stock objects indexed by validStocks?
Upvotes: 0
Views: 48
Reputation: 60522
I'm having a hard time trying to figure out exactly what you want, for example, what does:
expArray = expArray = expArray
mean? If you want an "array" of valid stocks, why not just create a list of reference objects
l = list(4)
l[["AAPL"]] = aStock
Upvotes: 1