[R] Filling array: No recycling
Prof Brian Ripley
ripley at stats.ox.ac.uk
Thu May 3 12:13:02 CEST 2007
How about
A <- array(NA, c(2,4) )
x <- 1:3
A[seq_along(x)] <- x
?
On Thu, 3 May 2007, 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.
>
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list