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
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")
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
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
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
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
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,
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
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
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))
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:
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
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
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
> 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
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
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
17 matches
Mail list logo