Alright guys i figured it out, no need to reply. Sorry for any bother...
PDXRugger wrote: > > Hey everyone, > Consider the below. I would like to look up each of the items in > "data" and store the result in "BinStore". In this example it isnt > storing any value but the last. In my actual code i am getting another > error altogether, i get a > > 1:In if (VacAcresVals.CandTaz <= 4) (BinNumber <- 1) ... : > the condition has length > 1 and only the first element will be used > 2: In if (VacAcresVals.CandTaz > 651) (BinNumber <- 10) ... : > the condition has length > 1 and only the first element will be used > > for each iteration. Thoughts about how to fix each of these issues. > Thanks guys > > data=c(1034.06001, 102.6600, 219.92000, 306.16001, 134.10000, > 21.13999, 363.08999, > 337.27000, 498.43999 , 429.28000, 234.08000, 51.82000 , 148.68999 , > 116.83999, > 14.33000 , 40.46001 , 59.00000 , 67.43000 , 60.88999 , 12.31001 , > 43.50000, > 128.37000 , 241.90000 ,223.77000 , 159.88000 , 45.63000 , 235.43999 , > 414.28999, > 75.05000 , 621.48999, 148.92000 ,814.66001 , 272.68000 , 108.98000 , > 49.05000, > 20.16001 , 33.13999 ,222.72000 , 677.52000 , 209.53999 , 511.70000, > 584.88000, > 143.12000 , 726.70000 ,472.43000 , 88.56001 , 89.51001 , 97.88999 > ,573.72000, > 176.36001 , 196.21001 , 267.63000 , 325.37000 , 421.75000 , 76.41001 , > 113.38999, > 31.70000 , 35.78999 , 76.62000 , 94.58999 ,140.92000, 80.16001 , > 471.78000, > 78.53999 , 341.48999 , 179.12000 , 98.83999 , 245.38999, 83.37000 > ,523.81001, > 799.22000 , 578.53999 , 246.01001 , 321.31001 ,489.63999 , 523.53000 , > 684.70000, > 1262.20000 , 937.90000 , 36.11001 ,101.76001 , 25.52000 , 77.47000 , > 49.70000, > 104.53999 , 20.50000 , 18.96001 , 14.31001) > > BinStore=list() > > > for (i in 1:length(data){ > IterData=data[i] > > if (IterData <= 4) > (BinNumber<-1) > if (IterData >4 && IterData<=7) > (BinNumber<-2) > if (IterData>7 && IterData<=17) > (BinNumber<-3) > if (IterData>17 && IterData<=28) > (BinNumber<-4) > if (IterData>28 && IterData<=50) > (BinNumber<-5) > if (IterData>50 && IterData<=91) > (BinNumber<-6) > if (IterData>91 && IterData<=151) > (BinNumber<-7) > if (IterData>151 && IterData<=341) > (BinNumber<-8) > if (IterData>341 && IterData<=651) > (BinNumber<-9) > if (IterData>651) > (BinNumber<-10) > > BinStore[[i]]=BinNumber > > > } > BinStore > -- View this message in context: http://www.nabble.com/Trouble-with-If-statements-tp24647922p24648049.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@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.