Re: [R] Subset dataframe with loop searching for unique values in two columns

2013-06-08 Thread arun
Hi, You could try this: dat2<- read.table(text='  case pin some_data  "A"  "1" "data"  "A"  "2" "data"  "A"  "1" "data"  "A"  "2" "data"  "B"  "1" "data"  "B"  "2" "data" ',sep="",header=TRUE,stringsAsFactors=FALSE)  dat2[!duplicated(dat2[,1:2]),] #  case pin some_data #1    A   1  data

Re: [R] subset dataframe

2013-04-22 Thread Mihai Nica
Thanks Arun, Jorge,s idea worked... I can't believe I lost so much time with this...   mike > > From:arun >To: Mihai Nica >Cc: R help >Sent: Monday, April 22, 2013 4:57 PM >Subject:Re: [R] subset dataframe > > >HI, >Could you provide an example dataset? >

Re: [R] subset dataframe

2013-04-22 Thread arun
6304 # $ X2000: int  24950 15292 25260 A.K. - Original Message - From: arun To: Mihai Nica Cc: R help Sent: Monday, April 22, 2013 5:57 PM Subject: Re: [R] subset dataframe HI, Could you provide an example dataset? set.seed(15) agoa<- data.frame(X.1=rep(c("AGOA","

Re: [R] subset dataframe

2013-04-22 Thread arun
HI, Could you provide an example dataset? set.seed(15) agoa<- data.frame(X.1=rep(c("AGOA","GSP","CST"),3),X1996= sample(1:2,9,replace=TRUE),X2000=sample(40:3,9,replace=TRUE))  str(agoa) #'data.frame':    9 obs. of  3 variables: # $ X.1  : Factor w/ 3 levels "AGOA","CST","GSP": 1 3 2 1 3 2

Re: [R] subset dataframe

2013-04-22 Thread Jorge I Velez
Mike, You need subset(agoa, agoa$X.1 == "AGOA ") instead of subset(agoa, agoa$X.1 == "AGOA") (note the space after the last A in "AGOA". HTH, Jorge.- On Tue, Apr 23, 2013 at 7:14 AM, Mihai Nica wrote: > I can't understand what is happening. This is the code and results: > > > agoa <- read

Re: [R] subset dataframe/list

2009-06-01 Thread Jorge Ivan Velez
Dear Cecilia, I have followed the replies you got and I found that, perhaps, what you are experiencing has something to do with the decimal symbol in your data. Consider the following: # Reading the data as you sent it to the list x <- read.table(textConnection("caedois b1 b2

Re: [R] subset dataframe/list

2009-06-01 Thread David Winsemius
So now is the time to back up to the beginning and demonstrate how you created the coeficientes object. Ideally you would also provide the results of: dput(coeficientes) or str(coeficientes) Subset will only work with dataframes, so if coeficientes is not a dataframe, then you will need

Re: [R] subset dataframe/list

2009-06-01 Thread Cecilia Carmo
It doesn't work. b1 was substituted by NA's with this message: Warning message: NAs introduced by coercion I will see in the webpage that you mentioned. Thanks, Cecília Em Mon, 1 Jun 2009 13:23:12 -0400 David Winsemius escreveu: On Jun 1, 2009, at 1:01 PM, Cecilia Carmo wrote: Hi R-help

Re: [R] subset dataframe/list

2009-06-01 Thread David Winsemius
On Jun 1, 2009, at 1:01 PM, Cecilia Carmo wrote: Hi R-helpers! I have the following object: head(coeficientes) caedois b1 b2 b3 1 10,033120395 -20,29478338 -0,274638864 2 2 -0,040629634 74,54239889 -0,069958424 3 5 -0,001116816 35

Re: [R] subset dataframe by number of rows of equal values

2009-05-24 Thread jim holtman
Here is one way of doing it: > moreThan <- ave(choose$code, choose$code, FUN=length) > moreThan [1] 2 2 4 4 4 4 2 2 6 6 6 6 6 6 > choose[moreThan > 2,] firm year code 3 2 2000 11 4 2 2001 11 5 2 2002 11 6 2 2003 11 9 4 2001 13 104 2002 13 114 2003 13 1

Re: [R] subset dataframe by rows using character vector?

2009-04-14 Thread baptiste auguie
ch appreciate your help, thanks again. Zack CC: r-help@r-project.org From: ba...@exeter.ac.uk To: zack_hol...@hotmail.com Subject: Re: [R] subset dataframe by rows using character vector? Date: Tue, 14 Apr 2009 15:56:45 +0100 Is this what you want? plotNam

Re: [R] subset dataframe by rows using character vector?

2009-04-14 Thread baptiste auguie
Is this what you want? plotNames <- c("plot1", "plot2", "plot3") # plot is probably best left as the name of the base function full.data[full.data$PLOTID %in% plotNames, ] # note the comma HTH, baptiste On 14 Apr 2009, at 15:20, zack holden wrote: Dear List, I'm stuck on what seems