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 [[alternative HTML version deleted]]
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, > Amorx1 <- 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
Amor, You have the possibility to use the duplicated() function. A[!duplicated(A[,var]),] Atenciosamente, Leandro Lins Marino Centro de Avalia??o Funda??o CESGRANRIO Rua Santa Alexandrina, 1011 - 2? andar Rio de Janeiro, RJ - CEP: 20261-903 R (21) 2103-9600 R.:236 ( (21) 8777-7907 ( leandro at cesgranrio.org.br "Aquele que suporta o peso da sociedade ? precisamente aquele que obt?m as menores vantagens". (SMITH, Adam) ? Antes de imprimir pense em sua responsabilidade e compromisso com o MEIO AMBIENTE -----Mensagem original----- De: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] Em nome de amor Gandhi Enviada em: ter?a-feira, 12 de maio de 2009 09:30 Para: r-help at stat.math.ethz.ch Assunto: [R] SAS PROC SORT nodupkey 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 [[alternative HTML version deleted]]