Hello! I have an algorithm which performs lengthy operations and I would like to cache results. Other languages usually offer a dictionary data type which I can use as an efficient way to dynamically cache already calculated results - what's the best way to do this in R? Best wishes, Sven C. Koehler
> cache results. Other languages usually offer a dictionary data type > which I can use as an efficient way to dynamically cache already > calculated results - what's the best way to do this in R?It really depends on what sort of data you want to cache - if it is fundamentally 1D, use a vector, 2D use a matrix etc. The closest equivalent to dictionary/hashmap is a list - however R's pass a copy semantics might slow things down if you are caching a lot of data. Hadley Wickham had.co.nz
AFAIK R does copy-on-modify, so if you call f(aList, ...) and inside f() aList is not modified, then a copy is not really made. Andy> From: hadley wickham > > > cache results. Other languages usually offer a dictionary data type > > which I can use as an efficient way to dynamically cache already > > calculated results - what's the best way to do this in R? > > It really depends on what sort of data you want to cache - if it is > fundamentally 1D, use a vector, 2D use a matrix etc. The closest > equivalent to dictionary/hashmap is a list - however R's pass a copy > semantics might slow things down if you are caching a lot of data. > > Hadley Wickham > had.co.nz > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > R-project.org/posting-guide.html > > >