[R] if else lop

gary engstrom engstrom.gary at gmail.com
Tue Jul 5 22:27:41 CEST 2011


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



More information about the R-help mailing list