[R] sample matrix

Ferdinand Alimadhi falimadhi at iq.harvard.edu
Tue Dec 13 17:16:12 CET 2005


Hi Mauricio,
Although you question is not clear, I'm supposing that you want to save 
as a new object (matrix) whatever is printed out from "cat(x,m,"\n")".
If this is the case, then your result is a matrix with 5 rows and 4 
columns. For each row, the first 3 values are "x" and the last value is "m".
Maybe this will help you.

>pulse <- c(67, 67, 68, 68, 68, 69, 69, 69, 69, 69, 70, 70, 70, 70, 71, 
>71, 72, 72, 73, 74)
>m <- NULL
>x <- 0
>  
>
result<- matrix(0, 5,4)

>for (i in 1:5)
>{
>x <- sample(pulse,3)
>  
>
result[i,1:3]<-x

>m <- mean(x)
>  
>
result[i,4]<-m

>cat(x,m,"\n")
>}
>
>  
>
Hopefully the object that you wanted is "result"


HTH

>Thanks,
>Mauricio
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>  
>


-- 
Ferdinand Alimadhi
Programmer / Analyst
Harvard University
The Institute for Quantitative Social Science
(617) 496-0187
falimadhi at latte.harvard.edu
www.iq.harvard.edu




More information about the R-help mailing list