Re: [R] Subsetting a data frame

2011-12-05 Thread jim holtman
does this do what you want: > db <- structure(list(ind = c("ind1", "ind2", "ind3", "ind4"), test1 = c(1, + 2, 1.3, 3), test2 = c(56L, 27L, 58L, 2L), test3 = c(1.1, 28, + 9, 1.2)), .Names = c("ind", "test1", "test2", "test3"), class = + "data.frame", row.names = c(NA, + -4L)) > > terms_include <- c

[R] Subsetting a data frame

2011-12-05 Thread natalie.vanzuydam
Hi R users, I really need help with subsetting data frames: I have a large database of medical records and I want to be able to match patterns from a list of search terms . I've used this simplified data frame in a previous example: db <- structure(list(ind = c("ind1", "ind2", "ind3", "ind4")

Re: [R] Subsetting a data frame with multiple values and exclusions.

2011-10-06 Thread natalie.vanzuydam
Thanks. Such a short and sweet answer that does what it should. - Natalie Van Zuydam PhD Student University of Dundee nvanzuy...@dundee.ac.uk -- View this message in context: http://r.789695.n4.nabble.com/Subsetting-a-data-frame-with-multiple-values-and-exclusions-tp3874967p3877472.html Sen

Re: [R] Subsetting a data frame with multiple values and exclusions.

2011-10-05 Thread Dennis Murphy
Hi: Is this what you're after? f <- function(x) !any(x %in% terms_exclude) && any(x %in% terms_include) db[apply(db[, -1], 1, f), ] ind test1 test2 test3 2 ind2 227 28.0 4 ind4 3 2 1.2 HTH, Dennis On Wed, Oct 5, 2011 at 8:53 AM, natalie.vanzuydam wrote: > Hi all, > > I

[R] Subsetting a data frame with multiple values and exclusions.

2011-10-05 Thread natalie.vanzuydam
Hi all, I realise that the convention is to provide a working example of my problem but the data are of a sensitive nature so I'm not able to do that in this case. I need to query a database for multiple search terms: db <- structure(list(ind = c("ind1", "ind2", "ind3", "ind4"), test1 = c(1, 2

Re: [R] Subsetting a data frame by dropping correlated variables

2011-04-27 Thread Juliet Hannah
The 'findCorrelation' function in the caret package may be helpful. On Tue, Apr 19, 2011 at 3:10 PM, Rita Carreira wrote: > > Hello R Users! > I have a data frame that has many variables, some with missing observations, > and some that are correlated with each other. I would like to subset the

[R] Subsetting a data frame by dropping correlated variables

2011-04-19 Thread Rita Carreira
Hello R Users! I have a data frame that has many variables, some with missing observations, and some that are correlated with each other. I would like to subset the data by dropping one of the variables that is correlated with another variable that I will keep int he data frame. Alternatively,

Re: [R] subsetting a data frame

2008-09-06 Thread Jorge Ivan Velez
oseph > > - Original Message > From: Jorge Ivan Velez <[EMAIL PROTECTED]> > To: joseph <[EMAIL PROTECTED]> > Sent: Saturday, September 6, 2008 10:43:09 AM > Subject: Re: [R] subsetting a data frame > > > Dear Joseph, > Try > > > DF[sapply(st

Re: [R] subsetting a data frame

2008-09-06 Thread stephen sefick
ssage >> From: Jorge Ivan Velez <[EMAIL PROTECTED]> >> To: joseph <[EMAIL PROTECTED]> >> Sent: Saturday, September 6, 2008 10:43:09 AM >> Subject: Re: [R] subsetting a data frame >> >> >> Dear Joseph, >> Try >> >> DF

Re: [R] subsetting a data frame

2008-09-06 Thread stephen sefick
h <[EMAIL PROTECTED]> > Sent: Saturday, September 6, 2008 10:43:09 AM > Subject: Re: [R] subsetting a data frame > > > > Dear Joseph, > > Try > > > DF[sapply(strsplit(as.character(DF$V3), ":"), > function(i) all(as.numeric(i) == 10))

Re: [R] subsetting a data frame

2008-09-06 Thread joseph
nt: Saturday, September 6, 2008 10:43:09 AM Subject: Re: [R] subsetting a data frame Dear Joseph, Try DF[sapply(strsplit(as.character(DF$V3), ":"), function(i) all(as.numeric(i) == 10)), ] HTH, Jorge On Sat, Sep 6, 2008 at 1:24 PM, joseph <[EMAIL PROTECTED]> wrote:

Re: [R] subsetting a data frame

2008-09-06 Thread joseph
ject: Re: [R] subsetting a data frame on 09/03/2008 05:06 PM joseph wrote: > I have a data frame that looks like this: > V1 V2 V3 > ab0:1:12 > df1:2:1 > cd1:0:9 > where V3 is in the form x:y:z > Can someone show me how to subset the rows where the values of

Re: [R] subsetting a data frame

2008-09-03 Thread Marc Schwartz
on 09/03/2008 05:06 PM joseph wrote: > I have a data frame that looks like this: > V1 V2 V3 > ab0:1:12 > df1:2:1 > cd1:0:9 > where V3 is in the form x:y:z > Can someone show me how to subset the rows where the values of x, y and z <= > 10: > V1 V2 V3 > df1:2:1 > c

[R] subsetting a data frame

2008-09-03 Thread joseph
I have a data frame that looks like this: V1 V2 V3 ab0:1:12 df1:2:1 cd1:0:9 where V3 is in the form x:y:z Can someone show me how to subset the rows where the values of x, y and z <= 10: V1 V2 V3 df1:2:1 cd1:0:9 Thanks Joseph [[alternative

Re: [R] subsetting a data frame using string matching

2008-01-21 Thread Richard . Cotton
> a = c("Alpha", "Beta", "Gamma", "Beeta", "Alpha", "beta") > b = c(1:6) > example = data.frame("Title" = a, "Vals" = b) > > > > example > Title Vals > 1 Alpha1 > 2 Beta2 > 3 Gamma3 > 4 Beeta4 > 5 Alpha5 > 6 beta6 > > > > I would like to be able to get a new data fra

Re: [R] subsetting a data frame using string matching

2008-01-21 Thread Chuck Cleland
On 1/21/2008 5:18 AM, Karin Lagesen wrote: > Example data frame: > > > a = c("Alpha", "Beta", "Gamma", "Beeta", "Alpha", "beta") > b = c(1:6) > example = data.frame("Title" = a, "Vals" = b) > > >> example > Title Vals > 1 Alpha1 > 2 Beta2 > 3 Gamma3 > 4 Beeta4 > 5 Alpha5

[R] subsetting a data frame using string matching

2008-01-21 Thread Karin Lagesen
Example data frame: a = c("Alpha", "Beta", "Gamma", "Beeta", "Alpha", "beta") b = c(1:6) example = data.frame("Title" = a, "Vals" = b) > example Title Vals 1 Alpha1 2 Beta2 3 Gamma3 4 Beeta4 5 Alpha5 6 beta6 > I would like to be able to get a new data frame from