Re: [R] Subset function

2011-09-09 Thread William Dunlap
d is faster. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of Rainer > Schuermann > Sent: Friday, September 09, 2011 5:44 AM > To: r-help@r-project.org;

Re: [R] Subset function

2011-09-09 Thread stat.kk
Thank you very much :) stat.kk -- View this message in context: http://r.789695.n4.nabble.com/Subset-function-tp3801397p3801626.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mai

Re: [R] Subset function

2011-09-09 Thread stat.kk
No :( I dont have a condition on variable but on row name. My data frame looks like (from your example): > x xin xout Peter1 14 Tom 8 5 Jane 16 884 Paul 114 Cathy 8 5

Re: [R] Subset function

2011-09-09 Thread Jean V Adams
Rainer provided an example of subsetting by the value of a variable in the data frame. Below is an example of subsetting by the value of the row name of the data frame. df <- data.frame(var1=1:10, var2=letters[1:10], var3=sample(10), row.names=month.abb[1:10]) subset(df, subset = row.name

Re: [R] Subset function

2011-09-09 Thread Rainer Schuermann
Does that help: > x xin xout 1 1 14 2 85 3 16 884 4 1 14 5 85 6 16 884 > subset( x, x$xin > 7, select = xout )

[R] Subset function

2011-09-09 Thread stat.kk
Hi, can anyone help me how to use 'subset' function on my data frame? I have created data frame 'data' with a few variables and with row names. Now I would like to subset rows with concrete row names. Using data[] I know how to do it. But I dont know how to formulate the subset condition: subset(

Re: [R] subset function unexpected behavior

2010-02-02 Thread Thomas Lumley
On Tue, 2 Feb 2010, David Katz wrote: Thanks, that helps! Subset creates a new context where a name clash can occur. So if I don't want to check for that possibility, I should use a special kind of index like .sch, or avoid subset: for(sch in school.list){ print(sch) print(input.data[input.d

Re: [R] subset function unexpected behavior

2010-02-02 Thread David Katz
Thanks, that helps! Subset creates a new context where a name clash can occur. So if I don't want to check for that possibility, I should use a special kind of index like .sch, or avoid subset: for(sch in school.list){ print(sch) print(input.data[input.data[,school.var] == sch,])} which work

Re: [R] subset function unexpected behavior

2010-02-02 Thread Dennis Murphy
Hi: Try this for your second loop instead: for(s in school.list){ print(s) print(subset(input.data, sch == s)) } [1] 1 sch pop 1 1 100 2 1 200 [1] 2 sch pop 3 2 300 4 2 400 Don't confound the 'sch' variable in your data frame with the index in your loop :) HTH, Dennis On Mon,

[R] subset function unexpected behavior

2010-02-02 Thread David Katz
I was surprised to see this unexpected behavior of subset in a for loop. I looked in subset.data.frame and it seemed to me that both versions should work, since the subset call should be evaluated in the global environment - but perhaps I don't understand environments well enough. Can someone enli

Re: [R] Subset function: selecting variables within a factor

2009-04-13 Thread Thomas Lumley
On Tue, 14 Apr 2009, Andrew McFadden wrote: Hi all I know this must be an easy one so sorry for the trouble. I would like to select a list of variables within a factor The following example is given in help for subset: subset(airquality, Temp > 80 select = c(Ozone, Temp)) So how do I select

[R] Subset function: selecting variables within a factor

2009-04-13 Thread Andrew McFadden
Hi all I know this must be an easy one so sorry for the trouble. I would like to select a list of variables within a factor The following example is given in help for subset: subset(airquality, Temp > 80 select = c(Ozone, Temp)) So how do I select all temperatures of 90 and 80 ie Temp = c(80,9

Re: [R] subset function within a function

2008-07-03 Thread Henrique Dallazuanna
I think that you can use split fot this, see ?split On Thu, Jul 3, 2008 at 6:25 PM, Lana Schaffer <[EMAIL PROTECTED]> wrote: > Hi, > I am using this subset statement and it works > outside a function. > LIS[[i]]<- lapply(LI, subset, select=cov[[i]]) > However, wrapped inside a function this stat

[R] subset function within a function

2008-07-03 Thread Lana Schaffer
Hi, I am using this subset statement and it works outside a function. LIS[[i]]<- lapply(LI, subset, select=cov[[i]]) However, wrapped inside a function this statement produces the same values for every LIS[[1]] which is only the first subset of LI. Does anyone know why is not working correctly ins