Thank you very much indeed. PD's code is exactly what I was looking for, and
unfortunately it is so obvious, that I could kick myself for not thinking of it
in the first place, as I feared would happen.
WM: thanks for the additional suggestion. I'll check it in detail to see how my
codes can be
Hello Wolfgang,
Building on Peter Dalgaard's code, are you just trying to take a sample of
a random column from each row? You don't need to use apply:
> array[cbind(1:nrow(array), sample.int(ncol(array), nrow(array),
replace=TRUE ))]
Just a general note, since you're sampling one-column-per-row
array[cbind(1:999,vector)]
-pd
On 01 Mar 2017, at 14:28 , Wolfgang Waser wrote:
> Dear all,
>
> I have to pick one value per row from an array, but from row to row from
> a different column. The column positions of the values for each row are
> stored in a vector.
>
> array: 999 rows, 48 col
Dear all,
I have to pick one value per row from an array, but from row to row from
a different column. The column positions of the values for each row are
stored in a vector.
array: 999 rows, 48 columns
vector: 999 values (each between 1 and 48) indicating for each row which
value to pick from t
4 matches
Mail list logo