Re: [R] questions on data management

From: Jacques VESLOT <jacques.veslot_at_good.ibl.fr>
Date: Thu 06 Jul 2006 - 21:26:49 EST

mnu <- unique(mn[order(mn$m,mn$n),])
mnu$p <- table(paste(mn$m, mn$n))

merge(mnu[sample(1:nrow(mnu), size=3, prob=mnu$p, replace=F), c("m","n")], xy, by.x=c("m","n"), by.y=c("x","y"))



Jacques VESLOT

CNRS UMR 8090
I.B.L (2ème étage)
1 rue du Professeur Calmette
B.P. 245
59019 Lille Cedex

Tel : 33 (0)3.20.87.10.44
Fax : 33 (0)3.20.87.10.31

http://www-good.ibl.fr


zhijie zhang a écrit :
> Dear friends,
> suppose i have two datasets: A and B
> A:
> id<-1:6
> x<-c(1,2,3,4,5,6)
> y<-c(2,4,6,8,3,2)
> xy<-data.frame(id,x,y)
> B
> m<-c(1,1,3,3,5,5)
> n<-c(2,2,6,6,3,3)
> mn<-data.frame(m,n)
> Now, i want to perfomr two tasks:
> 1. get a subset of B,no duplicate values,:
> C:
> m n
> 1 2
> 3 6
> 5 3
>
> 2.Extract the values in A on the conditions that x=m and y=n
> the results should be:
> id x y
> 1 1 2
> 3 3 6
> 5 5 3
> Thanks very much!
>
>
>
>



R-help@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 Received on Thu Jul 06 21:30:56 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 06 Jul 2006 - 22:15:15 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.