[R] simple subset question

2012-12-02 Thread Felipe Carrillo
 Hi, Consider the small dataset below, I want to subset by two variables in one line but it wont work...it works though if I subset separately. I have to be missing something obvious that I did not realize before while using subset.. fish - structure(list(IDWeek = c(27L, 28L, 29L, 30L, 31L, 32L,

Re: [R] simple subset question

2012-12-02 Thread Anthony Damico
shouldn't you just change b to x and winter to fish? :) On Sun, Dec 2, 2012 at 12:21 PM, Felipe Carrillo mazatlanmex...@yahoo.comwrote: Hi, Consider the small dataset below, I want to subset by two variables in one line but it wont work...it works though if I subset separately. I have to

Re: [R] simple subset question

2012-12-02 Thread David Winsemius
On Dec 2, 2012, at 9:21 AM, Felipe Carrillo wrote: Hi, Consider the small dataset below, I want to subset by two variables in one line but it wont work...it works though if I subset separately. I have to be missing something obvious that I did not realize before while using subset..

Re: [R] simple subset question

2012-12-02 Thread R. Michael Weylandt
On Sun, Dec 2, 2012 at 5:21 PM, Felipe Carrillo mazatlanmex...@yahoo.com wrote: Hi, Consider the small dataset below, I want to subset by two variables in one line but it wont work...it works though if I subset separately. I have to be missing something obvious that I did not realize before

Re: [R] simple subset question

2012-12-02 Thread Gerrit Eichner
Hi, Felipe, two typos? See below! On Sun, 2 Dec 2012, Felipe Carrillo wrote:  Hi, Consider the small dataset below, I want to subset by two variables in one line but it wont work...it works though if I subset separately. I have to be missing something obvious that I did not realize before

Re: [R] simple subset question

2012-12-02 Thread Felipe Carrillo
/rbdd_jsmp.aspx From: R. Michael Weylandt michael.weyla...@gmail.com To: Felipe Carrillo mazatlanmex...@yahoo.com Cc: r-help@r-project.org r-help@r-project.org Sent: Sunday, December 2, 2012 9:42 AM Subject: Re: [R] simple subset question On Sun, Dec 2, 2012 at 5:21 PM, Felipe Carrillo mazatlanmex

Re: [R] simple subset question

2012-12-02 Thread Felipe Carrillo
://www.fws.gov/redbluff/rbdd_jsmp.aspx From: arun smartpink...@yahoo.com To: Felipe Carrillo mazatlanmex...@yahoo.com Cc: R help r-help@r-project.org; R. Michael Weylandt michael.weyla...@gmail.com Sent: Sunday, December 2, 2012 10:29 AM Subject: Re: [R] simple subset question Hi, I am getting

Re: [R] simple subset question

2012-12-02 Thread R. Michael Weylandt
On Sun, Dec 2, 2012 at 6:46 PM, Felipe Carrillo mazatlanmex...@yahoo.com wrote: Works with the small dataset (2 years) but I get the error message with the whole dataset (12 years of data). I am going to have to check what's wrong with it...Thanks Off the cuff guess: there's a NA in Total so

Re: [R] simple subset question

2012-12-02 Thread William Dunlap
michael.weyla...@gmail.com Cc: r-help@r-project.org r-help@r-project.org Sent: Sunday, December 2, 2012 1:25 PM Subject: Re: [R] simple subset question Sorry, I was trying it to subset from a bigger dataset called 'winter' and forgot to change the variable names when I asked the question

Re: [R] simple subset question

2012-12-02 Thread Felipe Carrillo
Cc: R help r-help@r-project.org Sent: Sunday, December 2, 2012 11:00 AM Subject: RE: [R] simple subset question I am still getting an error message with :   x - subset(fish,Year==2012 Total==max(Total));x I get: [1] IDWeek Total  Fry    Smolt  FryEq  Year 0 rows (or 0-length row.names

Re: [R] simple subset question

2012-12-02 Thread David Winsemius
: RE: [R] simple subset question I am still getting an error message with : x - subset(fish,Year==2012 Total==max(Total));x I get: [1] IDWeek Total FrySmolt FryEq Year 0 rows (or 0-length row.names) The above is not an error message. It says that there are no rows satisfying your

Re: [R] simple subset question

2012-12-02 Thread Felipe Carrillo
/redbluff/rbdd_jsmp.aspx From: David Winsemius dwinsem...@comcast.net To: Felipe Carrillo mazatlanmex...@yahoo.com Cc: William Dunlap wdun...@tibco.com; arun smartpink...@yahoo.com; R help r-help@r-project.org Sent: Sunday, December 2, 2012 11:54 AM Subject: Re: [R] simple subset question

Re: [R] simple subset question

2012-12-02 Thread arun
-help@r-project.org r-help@r-project.org Sent: Sunday, December 2, 2012 1:25 PM Subject: Re: [R] simple subset question Sorry, I was trying it to subset from a bigger dataset called 'winter' and forgot to change the variable names when I asked the question. David W suggestion works but the strange

Re: [R] simple subset question

2012-12-02 Thread arun
...@tibco.com; arun smartpink...@yahoo.com Cc: R help r-help@r-project.org Sent: Sunday, December 2, 2012 2:34 PM Subject: Re: [R] simple subset question Using my whole dataset I get: library(plyr) ddply(winter,Year,summarise,maxTotal=max(Total))  fish - structure(list(Year = 2002:2012, maxTotal = c

Re: [R] simple subset question

2012-12-02 Thread Felipe Carrillo
mazatlanmex...@yahoo.com Cc: William Dunlap wdun...@tibco.com; David Winsemius dwinsem...@comcast.net; R help r-help@r-project.org Sent: Sunday, December 2, 2012 1:18 PM Subject: Re: [R] simple subset question Hi, From the ddply() output, you could get the whole row by:  fish1 - structure(list(Year

Re: [R] simple subset question

2012-12-02 Thread David L Carlson
From: arun smartpink...@yahoo.com To: Felipe Carrillo mazatlanmex...@yahoo.com Cc: William Dunlap wdun...@tibco.com; David Winsemius dwinsem...@comcast.net; R help r-help@r-project.org Sent: Sunday, December 2, 2012 1:18 PM Subject: Re: [R] simple subset question Hi, From

Re: [R] simple subset question

2012-12-02 Thread Felipe Carrillo
PM Subject: RE: [R] simple subset question As David W. guessed. The maximum is in year 2005 not 2012 so no row from 2012 matches the maximum. subset(winter,Year==2012 Total==max(Total)) [1] IDWeek Total  Fry    Smolt  FryEq  Year  0 rows (or 0-length row.names) winter[which(winter$Total==max