[R] if else lop

Sarah Goslee sarah.goslee at gmail.com
Tue Jul 5 22:36:50 CEST 2011


Gary,

Was the second half of my message this morning not clear enough?

It wasn't clear from your original message that you were using isin()
from the prob package, rather than using isin() as pseudocode, so I'd
written a function to do that part. But the second half of my message
went through the if() part of your question. If it doesn't do what you
want, you need to be clearer about what you need that it doesn't do.

Sarah

On Tue, Jul 5, 2011 at 4:27 PM, gary engstrom <engstrom.gary at gmail.com> wrote:
> I am trying to use if...else loop and have included a code snippet which I
>
>  might like to expand.
>  Maybe you could steer me in the right direction.
>  library(stats)
>  library(prob)
>  {
>   a <- sample ( 1:4,100, replace=T,prob=c(0.1,0.2,0.5,0.3))
>  b<-sample(3:6,100,replace=T,prob=c(0.2,0.2,0.2,0.4))
>  }
>  dd <- data.frame(a,b)
>  if (subset finds a vector) ( print that vector)
>  (else continue looking at subsets)
>  subset(dd,isin(dd,c(1,4), ordered = FALSE))
>  subset(dd,isin(dd,c(3,3),ordered=F))
>  Thank you
>  G
>


-- 
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-help mailing list