Creating an Array with different number of columns in R -
this not seem possible, guess thinking of how handle info incorrectly, not can't find way handle way envision. wanted create 3-dimensional array; thinking of relational database. dimensions have same number of rows, have different number of columns. example,
dimension 1 = 1 column, 20 unique location identifiers (rows) dimension 2 = 3 columns of abiotic variables associated 20 unique locations (rows) dimension 3 = 2 columns of biotic variables associated 20 unique locations (rows)i thinking best way set info go through each column , combine within abiotic or biotic using subscripting (e.g., apply function across varibles (columns) in 2nd (abiotic) dimension (e.g., dat[,,2] = log(dat[,,2]), might different want biotic variables.
this not treatment grouping type of analysis, don't want stacked info (where repeat unique locations 5 times multiple treatment options each location - makes no sense me these data, e.g.,
loc type var 1 ab 1 1 ab 2 1 ab 3 1 bi 1 1 bi 2
i frozen in way thinking these data. in past i've used arrays , subscripting intuitive me. can indeed create array has different number of columns in each dimension? if not, missing how handle these data? thoughts.
yes. can describing
# build 20 x 3 x 2 array dat <- array(data, c(20,3,2)) # illustration of applying functions on given dimension log(dat[,,2])
there no requirement dimensions of array as sized.
arrays r
No comments:
Post a Comment