> I am having trouble removing entries from a vector based on the value of the > vector and another object value. It works in my pseudo test run: > > DEV=400 > #Y > CANDS=c(100:105) > #Z > DEVS=c(120,220,320,420,520) > if(DEV>DEVS) > (CANDS=CANDS[which(DEV<DEVS)]) > CANDS DEVS > [1,] 100 120 > [2,] 101 220 > [3,] 102 320 > [4,] 103 420 > [5,] 104 520 > [6,] 105 620
The above code does not produce the output you show when I paste it into R. It would be highly desirable to have a short, documented, working example... > So the result CANDS is 103, 104 and 105 b/c the corresponding DEVS are > larger than the DEV(400 in this case). How do they correspond? Do you mean they are both columns of a data.frame as your example output suggests? But CANDS and DEVS are of differnt length, so this is probably not what you meant. Finally, your code seems to indicate that you want all elements of CANDS for which the corresponding (?) value of DEVS is less than threshold DEV, but only if DEV>DEVS. The latter produces a warning, as you are comparing a single value to a vector of 5, which is most likely not what you want. At this point my confusion is perfect and I give up. I think you need to give us a better explanantion of what data you have and what exactly you want to accomplish. cu Philipp -- Dr. Philipp Pagel Lehrstuhl für Genomorientierte Bioinformatik Technische Universität München Wissenschaftszentrum Weihenstephan 85350 Freising, Germany http://mips.gsf.de/staff/pagel ______________________________________________ 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.