[R] resizing data
diggsb at ohsu.edu
Fri Jan 25 23:41:36 CET 2013
On 1/25/2013 2:29 PM, emorway wrote:
> I played around with your example on the smaller dataset, and it seemed like
> it was doing what I wanted. However, applying it to the larger problem, I
> didn't get a resized 2D dataset that preserved the order I was hoping for.
> Hopefully the following illustrates the larger problem:
> # Now set the 70,000th element to 1 to find out where it ends up?
> # Iterating on columns first, then rows, the 70,000th element is
> # at index [10000,7]
> #  376 546
> # Does 1 appear at index [129,112] as I expect
> # (128 complete rows x 546 cols = 69888 + 112 = 70,000) thus, row 129, col
> #  0
> # No, so where is it?
> #  123293
> Where is that?
# row col
# [1,] 341 328
You need an extra transposition
y <- t(matrix(t(x), nrow=546))
#  1
# row col
# [1,] 129 112
Brian S. Diggs, PhD
Senior Research Associate, Department of Surgery
Oregon Health & Science University
More information about the R-help