Position-based substitution in arrays
// This is an alternative to using for loops to test each position
a <- array(0, dim=c(10, 10)) a[row(a) <= col(a)*2] <- 1
DZone Snippets > mroutley > array
12309 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Matthew Routley http://matt.routleynet.org
a <- array(0, dim=c(10, 10)) a[row(a) <= col(a)*2] <- 1