[R] Create Arrays
Gerrit.Eichner at math.uni-giessen.de
Gerrit.Eichner at math.uni-giessen.de
Fri Oct 15 11:17:12 CEST 2010
Hi, Doug,
maybe
columns <- c( 0, 3, 0, 2, 0, 1)
lapply( columns[ columns > 0],
function( o) array( -1, dim = c( 2, o)))
does what you want?
Regards -- Gerrit
---------------------------------------------------------------------
AOR Dr. Gerrit Eichner Mathematical Institute, Room 212
gerrit.eichner at math.uni-giessen.de Justus-Liebig-University Giessen
Tel: +49-(0)641-99-32104 Arndtstr. 2, 35392 Giessen, Germany
Fax: +49-(0)641-99-32109 http://www.uni-giessen.de/~gcb7
---------------------------------------------------------------------
Zitat von dpender <d.pender at civil.gla.ac.uk>:
>
> Hi,
>
> For this example:
>
> O <- c(0 0 0 2 0 0 2 0)
>
> I want to create an array every time O[i] > 0. The array should be in the
> form;
>
> R[j] <- array(-1, dim=c(2,O[i]))
>
> i.e. if O[i] > 0 4 times I want 4 R arrays.
>
> Does anyone have any suggestions?
>
> Thanks,
>
> Doug
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Create-Arrays-tp2996706p2996706.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org 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.
>
More information about the R-help
mailing list