[R] Filling array: No recycling

Petr Klasterecky klaster at karlin.mff.cuni.cz
Thu May 3 12:15:06 CEST 2007


First make your vectors to have the same length and then put them to the 
array.

 > x <- c(1,2)
 > x
[1] 1 2
 > length(x) <- 5
 > x
[1]  1  2 NA NA NA


Petr


Felix Wave napsal(a):
> 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.
> 

-- 
Petr Klasterecky
Dept. of Probability and Statistics
Charles University in Prague
Czech Republic



More information about the R-help mailing list