[R] SAS PROC SORT nodupkey

Chuck Cleland ccleland at optonline.net
Tue May 12 14:58:08 CEST 2009


On 5/12/2009 8:29 AM, amor Gandhi wrote:
> Hi,
>  
> I have the following data and I would like to delete douple names, it is almost similar to SAS PROC SORT nodupkey! Is there any function in R does this?
>  
> x1 <- rnorm(11,5,1)
> x2 <- runif(11,0,1)
> nam <-paste("A", c(1:4,4,5:9,9), sep=".")
> mydata <- data.frame(x1,x2)
> crownames(mydata) <- nam
>  
> Many thanks in advance,
> Amor 

x1 <- rnorm(11,5,1)

x2 <- runif(11,0,1)

nam <-paste("A", c(1:4,4,5:9,9), sep=".")

mydata <- data.frame(nam,x1,x2)

mydata[!duplicated(mydata$nam),]
   nam       x1         x2
1  A.1 5.418824 0.04867219
2  A.2 5.658403 0.18398337
3  A.3 4.458279 0.50975887
4  A.4 5.465920 0.16425144
6  A.5 3.769153 0.80380230
7  A.6 6.827979 0.13745441
8  A.7 5.353053 0.91418900
9  A.8 5.409866 0.41879708
10 A.9 5.041249 0.38226152

?duplicated

> 	[[alternative HTML version deleted]]
> 
> ------------------------------------------------------------------------
> 
> ______________________________________________
> R-help at r-project.org mailing list
> 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.

-- 
Chuck Cleland, Ph.D.
NDRI, Inc. (www.ndri.org)
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894




More information about the R-help mailing list