Re: [R] Find all numbers in a certain interval

2008-12-17 Thread Antje
Thanks a lot for every answer I got! I could solve my problem! Greg, your proposal seems to be quite useful for me :-) Thank you. Ciao, Antje Antje schrieb: Hi all, I'd like to know, if I can solve this with a shorter command: a <- rnorm(100) which(a > -0.5 & a < 0.5) # would give me all

Re: [R] Find all numbers in a certain interval

2008-12-17 Thread Vitalie Spinu
Hi, If you can formulate your question it in terms of actual problem you have with data.frame it would be easier to answer. for the time being check subset() if it is what you want. SV. On Tue, 16 Dec 2008 11:09:19 +0100, Antje wrote: Hi all, I'd like to know, if I can solve this with a sho

Re: [R] Find all numbers in a certain interval

2008-12-16 Thread Greg Snow
Here are a couple of function definitions that may be more intuitive for some people (see the examples below the function defs). They are not perfect, but my tests showed they work left to right, right to left, outside in, but not inside out. `%<%` <- function(x,y) { xx <- attr(x,'orig

Re: [R] Find all numbers in a certain interval

2008-12-16 Thread David Winsemius
On Dec 16, 2008, at 7:19 AM, Antje wrote: Hi David, thanks a lot for your proposal. I got a lot of useful hints from all of you :-) David Winsemius schrieb: It's not entirely clear what you are asking for, since which(within.interval(a, -0.5, 0.5)) is actually longer than which(a > -0.

Re: [R] Find all numbers in a certain interval

2008-12-16 Thread Duncan Murdoch
Antje wrote: Hi, sorry, but it shouldn't be "different". The result should be the same but I was looking if there is a method I can use... # having a function defined like baptiste proposed: isIn <- function (interval, x) { (x > min(interval)) & (x < max(interval)) } Along the lines

Re: [R] Find all numbers in a certain interval

2008-12-16 Thread Antje
Hi David, thanks a lot for your proposal. I got a lot of useful hints from all of you :-) David Winsemius schrieb: It's not entirely clear what you are asking for, since which(within.interval(a, -0.5, 0.5)) is actually longer than which(a > -0.5 & a < 0.5). Right but in case 'a' is someth

Re: [R] Find all numbers in a certain interval

2008-12-16 Thread Antje
Hi, sorry, but it shouldn't be "different". The result should be the same but I was looking if there is a method I can use... # having a function defined like baptiste proposed: isIn <- function (interval, x) { (x > min(interval)) & (x < max(interval)) } #-- a <- rno

Re: [R] Find all numbers in a certain interval

2008-12-16 Thread David Winsemius
It's not entirely clear what you are asking for, since which(within.interval(a, -0.5, 0.5)) is actually longer than which(a > -0.5 & a < 0.5). You mention that you want a solution that applies to dataframes. Using indexing you can get entire rows of dataframes that satisfy multiple condit

Re: [R] Find all numbers in a certain interval

2008-12-16 Thread Duncan Murdoch
Antje wrote: Hi all, I'd like to know, if I can solve this with a shorter command: a <- rnorm(100) which(a > -0.5 & a < 0.5) # would give me all indices of numbers greater than -0.5 and smaller than +0.5 I have something similar with a dataframe and it produces sometimes quite long commands.