Thank you Rui, that helped a lot. The correct values show up when I'm using the following code. Now fun(Temp,v) returns a matrix, and Temp and v stay the same. But I'd like to use the reduced vectors in some calculations..can they be "extracted" in some way so that I have them separately again?
fun <- function(Temp, v){ unwanted <- Temp <= 16 | Temp >= 38.5 Temp <- Temp[!unwanted] v <- v[!unwanted] list(Temp=Temp, v=v) } fun(Temp,v) PS: thank you too,andrija..but it's not what I'm looking for -- View this message in context: http://r.789695.n4.nabble.com/function-for-filtering-and-deleting-vector-entries-tp4432410p4436217.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.