[R] Filling array: No recycling

Robin Hankin r.hankin at noc.soton.ac.uk
Thu May 3 12:27:58 CEST 2007


Felix

I'm not quite sure I understand your example, but try:

a <- array(NA,c(2,2,3))
jj <- c(12,33,22)
a[1:length(jj)] <- jj
a

which will fill only the first three elemens of array "a"


HTH

rksh



On 3 May 2007, at 10:41, Felix Wave wrote:

> Hello,
> is it possible to fill an array with no using of the recycling rule?
> My problem. I want to fill an array but my values have not always
> the same length.
> My aim. I want to fill the array only ONE TIME. All vacent places
> should be written with NA.
>
>
>
> Thank's a lot.
> Felix
>
>
> Example:
> --------
>
> #Write 1 to 3 only one time. The last
> #5 place should be NA.
>
> dim(as.array(letters))
> array(1:3, c(2,4) )
>
> #na.strings = "NA"
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting- 
> guide.html
> and provide commented, minimal, self-contained, reproducible code.

--
Robin Hankin
Uncertainty Analyst
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
  tel  023-8059-7743



More information about the R-help mailing list