s-news
[Top] [All Lists]

Summary/Solution: sampling from list

To: <s-news@lists.biostat.wustl.edu>
Subject: Summary/Solution: sampling from list
From: Robert Anthony Canales <rcanales@Stanford.EDU>
Date: Tue, 31 Jul 2001 13:19:48 -0700 (PDT)
Nick Ellis offered an efficient solution to my previous question (copied
below).


Try, e.g.,

do.call("rbind",sample(grip,3,replace=T))

do.call() is very handy when you have a variable list or arguments to a
function. sample() seems to be able to take a list as its argument, even
though the documentation doesn't say so.


original question
Say I have a list (grip) composed of 5 matrices (grip1, grip2, grip3,
grip4, grip5).  Each matrix gives coordinates x and y (rows and columns)
which will later be used to fill in a larger matrix, z.grip.  For my
algorithm, I would like to randomly sample 1 or more (n) of the matrices
from the list and return their coordinates as a single matrix or directly
assign a value to the z.grip matrix by the output of the randomly sampled
matrix of coordinates.  Furthermore I would like to perform this operation
in 1 step, if possible.


<Prev in Thread] Current Thread [Next in Thread>
  • Summary/Solution: sampling from list, Robert Anthony Canales <=