Hello,

Please respond to the list, not just to me.
If you just want the first vector ofm the matrices, try the following.

fun <- function(..., n, replace = FALSE){
    m <- do.call(rbind, list(...))
    idx <- sample(nrow(m), n, replace = replace)
    m[idx, 1]
}

n <- 3 * nrow(Young.list1) * 0.25
fun(Young.list1, Young.list2, Young.list3, n = n, replace = FALSE)

Hope this helps,

Rui Barradas
Citando MARYAM <firoozi_maryam6...@yahoo.com>:

> Hello, I want to select randomly to three matrix with fixed  
> number.for example i want to select 25% from three matrix  
> randomly(select first column of each matrix). On Dey 30, 1394 AP, at  
> 0:05, ruipbarra...@sapo.pt wrote:
>  
>>  

Hello,

What do you want to sample? Rows? With or without replacement? You  
need to give us more information on what you want.

Start by seeing the help page for ?sample

Hope this helps,

Rui Barradas
 

Citando MARYAM <firoozi_maryam6...@yahoo.com>:

> Dear mr/madam
> I have 3 matrix with 20 rows and 3 columns like this: I want to  
> sample randomly from three matrix and put it in a vector.How can i  
> do that?
>
> Young.list1<- matrix(NA,nrow= 20,ncol=3)
> Young.list1[,1]<- 1:20
> Young.list1[,2]<- 0.6
> Young.list1[,3]<- 500
> colnames(Young.list1)<- c("ID","r","EBV")
> ###########################################
> Young.list2<- matrix(NA,nrow= 20,ncol=3)
> Young.list2[,1]<- 21:40
> Young.list2[,2]<- 0.7
> Young.list2[,3]<- 600
> colnames(Young.list2)<- c("ID","r","EBV")
> ###########################################
> Young.list3<- matrix(NA,nrow= 20,ncol=3)
> Young.list3[,1]<- 41:60
> Young.list3[,2]<- 0.8
> Young.list3[,3]<- 700
> colnames(Young.list3)<- c("ID","r","EBV")
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide  
> http://www.R-project.org/posting-guide.htmland[1] provide commented,  
> minimal, self-contained, reproducible code.

 

 

Ligações:
---------
[1] http://www.r-project.org/posting-guide.htmland

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to