[R] Change array size

Spencer Graves spencer.graves at pdf.com
Fri Feb 14 16:22:06 CET 2003


then change "trunc" to "ceiling"???

Peter Dalgaard BSA wrote:
> "Liaw, Andy" <andy_liaw at merck.com> writes:
> 
> 
>>Is the following what you want?
>>
>>
>>>x<- rnorm(800)
>>>xt <- x[1:2^trunc(log(length(x),base=2))]
>>>length(xt)
>>
>>[1] 512
> 
> 
> I don't think so (notice "upper"). More likely
> 
> x <- rnorm(800)
> l <- length(x)
> xt <- c(x,numeric(2^ceiling(log(l,base=2))-l))
> length(xt) # 1024
> 
> but "fits" might also imply interpolation?
> 
> 
>>>Hi,
>>>I would like to know if there is a way to change a vector of 
>>>arbitrary size
>>>to make it fits the nearest upper size multiple of a power of 2.
>>
> 
>




More information about the R-help mailing list