search for: bsum

Displaying 3 results from an estimated 3 matches for "bsum".

Did you mean: bsm
2024 Feb 28
3
Initializing vector and matrices
Is there as way to initialize a vector (matrix) with an unknown length (dimension)? NULL does not seem to work. The lines below work with a vector of length 4 and a matrix of 4 x 4. What if I do not know initially the length/dimension of the vector/matrix? All I want is to add up (accumulate)? the vector and matrix as I go through the loop. Or, are there other ways to accumulate such vectors
2008 Apr 04
4
Arbitrary Precision Numbers
...ject Euler question :)) If I wanted to calculate the sum of the digits in the decimal representation of 2^1000, what would be a good way to go about that? I've tried the following methods: # Calculate the sum of digits in the decimal representation of 2^n # Only works for smaller values of n bsum <- function(n) { s <- 0 e <- floor(log10(2^n)) for (i in seq(e,0,-1)) { s <- s + (((2^n) %/% 10^i) %% 10) } s } The above doesnt work, as I am using an integer modulus which has insufficient precision. so I tried to coerce R to produce a full-precision integer and sum the digit...
2006 Jul 27
6
Any interest in "merge" and "by" implementations specifically for sorted data?
Hi Developers, I am looking for another new project to help me get more up to speed on R and to learn something outside of R internals. One recent R issue I have run into is finding a fast implementations of the equivalent to the following SAS code: /* MDPC is an integer sort key made from two integer columns */ MDPC = (MD * 100000) + PCO; /* sort the dataset by the key */ PROC SORT;