Re: [R] Using sapply to build a count matrix

2009-07-01 Thread Marc Schwartz
On Jul 1, 2009, at 9:15 PM, Murray Cooper wrote: Dear All, I am new to R and slowly learning how to use the system. The following code is an exercise I was trying. The intent is to generate 10 random samples of size 5 from a vector with integers 1:10 and 2 missing values. I then want to genera

Re: [R] Using sapply to build a count matrix

2009-07-01 Thread Jorge Ivan Velez
Dear Murray, Here is one way: create a function that takes k sample()s from any vector (e.g., x) and then calculates the number of NA values in it. Then replicate the procedure as many times as you want. # The function foo <- function(x, k = 5){ xsample <- sample(x, k)

[R] Using sapply to build a count matrix

2009-07-01 Thread Murray Cooper
Dear All, I am new to R and slowly learning how to use the system. The following code is an exercise I was trying. The intent is to generate 10 random samples of size 5 from a vector with integers 1:10 and 2 missing values. I then want to generate a matrix, for each sample which shows the freque