hi, this may be trivial, but we can't seem to find anything adequate,
(although there is a work around with match() ). We are looking for something
along the lines of
plot(table1[table1$var2==or("a","b","c","d"),"var1"])
would be handy, with the potential or() function leading to what
plot(table1[table1$var2=="a" | table1$var2=="b" |
table1$var2=="c" |
table1$var2=="d","var1"])
would do.
thanks for any hint
----------------------------------------------
Dr. Sebastian Leuzinger
University of Basel, Department of Environmental Science
Institute of Botany
Sch?nbeinstr. 6 CH-4056 Basel
ph 0041 (0) 61 2673511
fax 0041 (0) 61 2673504
email Sebastian.Leuzinger at unibas.ch
web http://pages.unibas.ch/botschoen/leuzinger
Try this:
plot(table1[table1$var2 %in%
c("a","b","c","d"),"var1"])
On 07/01/2008, Sebastian Leuzinger <Sebastian.Leuzinger at unibas.ch>
wrote:> hi, this may be trivial, but we can't seem to find anything adequate,
> (although there is a work around with match() ). We are looking for
something
> along the lines of
>
>
plot(table1[table1$var2==or("a","b","c","d"),"var1"])
>
> would be handy, with the potential or() function leading to what
>
> plot(table1[table1$var2=="a" | table1$var2=="b" |
table1$var2=="c" |
> table1$var2=="d","var1"])
>
> would do.
> thanks for any hint
>
>
> ----------------------------------------------
> Dr. Sebastian Leuzinger
> University of Basel, Department of Environmental Science
> Institute of Botany
> Sch?nbeinstr. 6 CH-4056 Basel
> ph 0041 (0) 61 2673511
> fax 0041 (0) 61 2673504
> email Sebastian.Leuzinger at unibas.ch
> web http://pages.unibas.ch/botschoen/leuzinger
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Henrique Dallazuanna
Curitiba-Paran?-Brasil
25? 25' 40" S 49? 16' 22" O
look at ?"%in%"; I hope it helps.
Best,
Dimitris
----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven
Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
http://www.student.kuleuven.be/~m0390867/dimitris.htm
----- Original Message -----
From: "Sebastian Leuzinger" <Sebastian.Leuzinger at unibas.ch>
To: <r-help at stat.math.ethz.ch>
Sent: Monday, January 07, 2008 3:55 PM
Subject: [R] is there something like or() ?
hi, this may be trivial, but we can't seem to find anything adequate,
(although there is a work around with match() ). We are looking for
something
along the lines of
plot(table1[table1$var2==or("a","b","c","d"),"var1"])
would be handy, with the potential or() function leading to what
plot(table1[table1$var2=="a" | table1$var2=="b" |
table1$var2=="c" |
table1$var2=="d","var1"])
would do.
thanks for any hint
----------------------------------------------
Dr. Sebastian Leuzinger
University of Basel, Department of Environmental Science
Institute of Botany
Sch?nbeinstr. 6 CH-4056 Basel
ph 0041 (0) 61 2673511
fax 0041 (0) 61 2673504
email Sebastian.Leuzinger at unibas.ch
web http://pages.unibas.ch/botschoen/leuzinger
______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
You can say
table1$var2 %in% c("a","b","c","d")
--- Sebastian Leuzinger
<Sebastian.Leuzinger at unibas.ch> wrote:
> hi, this may be trivial, but we can't seem to find
> anything adequate,
> (although there is a work around with match() ). We
> are looking for something
> along the lines of
>
>
plot(table1[table1$var2==or("a","b","c","d"),"var1"])>
>
> would be handy, with the potential or() function
> leading to what
>
> plot(table1[table1$var2=="a" | table1$var2=="b" |
> table1$var2=="c" |
> table1$var2=="d","var1"])
>
> would do.
> thanks for any hint
>
>
> ----------------------------------------------
> Dr. Sebastian Leuzinger
> University of Basel, Department of Environmental
> Science
> Institute of Botany
> Sch?nbeinstr. 6 CH-4056 Basel
> ph 0041 (0) 61 2673511
> fax 0041 (0) 61 2673504
> email Sebastian.Leuzinger at unibas.ch
> web http://pages.unibas.ch/botschoen/leuzinger
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained,
> reproducible code.
>
The or() function is called any(). Similarly, the function you might expect to be called and() is all(). -thomas On Mon, 7 Jan 2008, Sebastian Leuzinger wrote:> hi, this may be trivial, but we can't seem to find anything adequate, > (although there is a work around with match() ). We are looking for something > along the lines of > > plot(table1[table1$var2==or("a","b","c","d"),"var1"]) > > would be handy, with the potential or() function leading to what > > plot(table1[table1$var2=="a" | table1$var2=="b" | table1$var2=="c" | > table1$var2=="d","var1"]) > > would do. > thanks for any hint > > > ---------------------------------------------- > Dr. Sebastian Leuzinger > University of Basel, Department of Environmental Science > Institute of Botany > Sch?nbeinstr. 6 CH-4056 Basel > ph 0041 (0) 61 2673511 > fax 0041 (0) 61 2673504 > email Sebastian.Leuzinger at unibas.ch > web http://pages.unibas.ch/botschoen/leuzinger > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >Thomas Lumley Assoc. Professor, Biostatistics tlumley at u.washington.edu University of Washington, Seattle