Hello This is a very newbie question on R syntax, but I do not find the answer.... I want to make a selection on an interval say choose Xint in the interval of temperatures 390-399 I tried this syntax Xint<- X[t>=390 && t< 400] typing >XintI get the answer numeric(0) it did not select any object! 'though I verified that there indeed are occrencies of X in this interval Any idea? thanks Anne
anne wrote:> Hello > > This is a very newbie question on R syntax, but I do not find the > answer.... > > I want to make a selection on an interval say choose Xint in the > interval of temperatures 390-399 > > I tried this syntax > Xint<- X[t>=390 && t< 400] typing >XintI get the answer numeric(0) > > it did not select any object! 'though I verified that there indeed are > occrencies of X in this interval > > > Any idea? > > thanks > > AnneThe idea is to read help("&&"). It tells you: "& and && indicate logical AND and | and || indicate logical OR. The shorter form performs elementwise comparisons in much the same way as arithmetic operators. The longer form evaluates left to right examining only the first element of each vector. Evaluation proceeds only until the result is determined. The longer form is appropriate for programming control-flow and typically preferred in if clauses." So I guess you want Xint <- X[(t >= 390) & (t < 400)] Uwe Ligges
anne <anne.piotet at urbanet.ch> writes:> Hello > > This is a very newbie question on R syntax, but I do not find the answer.... > > I want to make a selection on an interval say choose Xint in the > interval of temperatures 390-399 > > > I tried this syntax > Xint<- X[t>=390 && t< 400] typing >XintI get the answer numeric(0)Use &, not &&
I think you just want &, not &&. try: x <- 1:10 xint <- x[x>=4 & x < 7] xint At 05:57 PM 9/8/2003 +0200, anne wrote:>Hello > >This is a very newbie question on R syntax, but I do not find the answer.... > >I want to make a selection on an interval say choose Xint in the >interval of temperatures 390-399 > >I tried this syntax >Xint<- X[t>=390 && t< 400] >typing >XintI get the answer numeric(0) > >it did not select any object! 'though I verified that there indeed are >occrencies of X in this interval > > >Any idea? > >thanks > >Anne > >______________________________________________ >R-help at stat.math.ethz.ch mailing list >https://www.stat.math.ethz.ch/mailman/listinfo/r-help >With best wishes and kind regards I am Sincerely, Corey A. Moffet, Ph.D. Support Scientist University of Idaho Northwest Watershed Research Center 800 Park Blvd, Plaza IV, Suite 105 Boise, ID 83712-7716 Voice: (208) 422-0718 FAX: (208) 334-1502
Possibly Parallel Threads
- Modified F-test for heterogeneous error variances
- Is there a way to use CGIwithR in Windows?
- TableGen error message: top-level forms in instruction pattern should have void types
- What is the correct way of using function C() for factors:
- conditional less than