Thatis was not my original question. My original questions was how
memory is managed/allocated in R?
On Thu, Dec 10, 2009 at 6:08 PM, jim holtman wrote:
> If you really want to code like a C++ coder in R, then create your own
> object and extend it when necessary:
>
> # take a variation of this;
If you really want to code like a C++ coder in R, then create your own
object and extend it when necessary:
# take a variation of this; preallocate and then extend when you read a
limit
x <- numeric(2)
for (i in 1:100){
if (i > length(x)){
# double the length (or whatever you want)
I have a situation that I can not predict the final result's dimension.
In C++, I believe that the class valarray could preallocate some
memory than it is actually needed (maybe 2 times more). The runtime
for a C++ equivalent (using append) to the R code would still be C*n,
where C is a constant a
For the case below, you don't need to know anything about how R
manages memory, but you do need to understand basic concepts
algorithmic complexity. You might find "The Algorithm Design Manual",
http://www.amazon.com/dp/1848000693, a good start.
Hadley
On Thu, Dec 10, 2009 at 10:26 AM, Peng Yu
Related...
Rule of thumb:
Pre-allocate your object of the *correct* data type, if you know the
final dimensions.
/Henrik
On Thu, Dec 10, 2009 at 8:26 AM, Peng Yu wrote:
> I'm wondering where I can find the detailed descriptions on R memory
> management. Understanding this could help me understa
I'm wondering where I can find the detailed descriptions on R memory
management. Understanding this could help me understand the runtime of
R program. For example, depending on how memory is allocated (either
allocate a chuck of memory that is more than necessary for the current
use, or allocate th
6 matches
Mail list logo