Re: [R] subset problem

2012-03-30 Thread reeyarn
Thank you so much, Peter and Andrija :) On Thu, Mar 29, 2012 at 1:44 PM, peter dalgaard wrote: > %in% is your friend > mysub <- subset(df, type %in% type_list, select=c(name,type)) > or > mysub <- df[df$type %in% type_list, c("name","type")] > The latter is slightly safer if you can't be sure tha

Re: [R] subset problem

2012-03-28 Thread andrija djurovic
Hi. You can try this: df[type%in%type_list, ] You can also use sqldf package and subset data frames usign sql statements: library(sqldf) df <- data.frame(x1=1:10, type=10:1) type_list <- data.frame(index=seq(1,10,by=2)) sqldf("select df.* from df where df.type in (select * from ty

Re: [R] subset problem

2012-03-28 Thread peter dalgaard
On Mar 29, 2012, at 07:25 , reeyarn wrote: > Hi, > > If my data frame "df" has a index "type", I want to get a subset such > that the type belongs to a "type_list"; > using sql, I want > SELECT name, type FROM df >WHERE type in type_list; > > Now in R I have to write a loop like > mysubse

Re: [R] subset problem

2012-03-28 Thread reeyarn
Hi, If my data frame "df" has a index "type", I want to get a subset such that the type belongs to a "type_list"; using sql, I want SELECT name, type FROM df WHERE type in type_list; Now in R I have to write a loop like mysubset<- df [ df$type == type_list[1], ] for (type1 in type_list[

Re: [R] subset problem

2012-03-15 Thread Farley, Robert
ystem file > Robert Farley LACMTA -Original Message- From: jim holtman [mailto:jholt...@gmail.com] Sent: Wednesday, 14 March, 2012 20:36 To: Farley, Robert Cc: R-help@r-project.org Subject: Re: [R] subset problem Supply an 'str' of your dataframe so we can see what its

Re: [R] subset problem

2012-03-14 Thread jim holtman
Supply an 'str' of your dataframe so we can see what its structure is. Do you have leading/trailing blanks in your ROUTE values. Print them out and see what their number of characters (nchar) are. Are they factors? You have not supplied enough information like a small subset. I bet when you c

[R] subset problem

2012-03-14 Thread Farley, Robert
I'm having a simple problem with subset. I'm choosing what I think is a valid selection, but I either get everything or an empty dataframe. What am I doing wrong? > > describe(OBDataSumm) Description of OBDataSumm Numeric meanmedian varsd valid.n SAMP

Re: [R] Subset problem

2012-03-07 Thread RMSOPS
Thank you. I put table(factor(x.sub$RES_ID)) and works. -- View this message in context: http://r.789695.n4.nabble.com/Subset-problem-tp4452837p4452954.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing

Re: [R] Subset problem

2012-03-07 Thread Petr PIKAL
Hi > > Good Morning > > I have a small question regarding the function subset. > I am copying data from one table but I just want to collect data from a > user. > When do I take the view, presents the results I want. > > The problem arises when can I make the tab. for RES_ID, introduces me

[R] Subset problem

2012-03-07 Thread RMSOPS
Good Morning     I have a small question regarding the function subset. I am copying data from one table but I just want to collect data from a user. When do I take the view, presents the results I want. The problem arises when can I make the tab. for RES_ID, introduces me to zero results do not

Re: [R] subset problem (reducing from six to two levels)

2009-02-05 Thread Ine
Great, this worked for me, exactly how I needed it. Thanks for all the replies! Peter Dalgaard wrote: > > Ine wrote: >> Hi all, >> I have got a seemingly simple problem (I am an R starter) with subsetting >> my >> data set, but cannot figure out the solution: I want to subset a data set >> from

Re: [R] subset problem (reducing from six to two levels)

2009-02-05 Thread Stephan Kolassa
Hi, does this help? http://www.nabble.com/factor-question-to18638814.html#a18638814 HTH, Stephan Ine schrieb: Hi all, I have got a seemingly simple problem (I am an R starter) with subsetting my data set, but cannot figure out the solution: I want to subset a data set from six to two levels,

Re: [R] subset problem (reducing from six to two levels)

2009-02-05 Thread Peter Dalgaard
Ine wrote: Hi all, I have got a seemingly simple problem (I am an R starter) with subsetting my data set, but cannot figure out the solution: I want to subset a data set from six to two levels, so that all analyses are done only with these two remaining levels. I tried TOTAL<-read.delim('total.c

Re: [R] subset problem (reducing from six to two levels)

2009-02-05 Thread Philipp Pagel
On Thu, Feb 05, 2009 at 01:01:59PM -0800, Ine wrote: > > Hi all, > I have got a seemingly simple problem (I am an R starter) with subsetting my > data set, but cannot figure out the solution: I want to subset a data set > from six to two levels, so that all analyses are done only with these two >

[R] subset problem (reducing from six to two levels)

2009-02-05 Thread Ine
Hi all, I have got a seemingly simple problem (I am an R starter) with subsetting my data set, but cannot figure out the solution: I want to subset a data set from six to two levels, so that all analyses are done only with these two remaining levels. I tried TOTAL<-read.delim('total.csv',header=T