Displaying 1 result from an estimated 1 matches for "stk_class".
Did you mean:
starclass
2005 Jan 24
1
lookups and joins
...olumn, ie my lookup table.
stcl = read.csv("stockclass.csv")
stockclass = as.vector(stcl$stock_class)
# This gives me what appears to be a dictionary or map
names(stockclass) = as.vector(stcl$stock_group)
getstockclass = function(stock_group) {
try(stockclass[[stock_group]], TRUE)
}
csg$stk_class=factor(sapply(csg$stock_group, getstockclass))
I need the try since if there is a missing value I get an exception.
I also tried something along the lines of (from memory):
getstockclass = function(stock_group) {
stcl[which(stcl$stock_group == stock_group),]$stock_class
}
These work but I just...