On 6/3/2006 2:44 PM, [EMAIL PROTECTED] wrote: > Hi : I have old Splus code that I am trying to turn into R > ( I am using windows Xp and R 2.20 ) and I am getting a warning > from one of my statements because the behavior of R is different from Splus. > > below, tempdata is a matrix of numbers and > I have the following command which basically runs through the columns and > returns the minimum index of the column > where an NA occurs. > > badindices<-sapply(tempdata,function(x)min(bdind<-seq(along=x)[is.na(x)]))) > > The problems seems to be that, if the column doesn't have any NAs, > then I get the following warning : "no finite arguments to min : > returning inf". So, consequently, I get a lot of warnings > anfd -infs. > > I dont have Splus right now but from the code I have under > the above command it looks like Splus returned NA rather than -inf and didn't > give any warnings. This would be the the way > I would prefer it to be handled. So, I was > hoping that there is there a way to avoid getting these > warning and get the behavior that Splus gave me by modifying > the code or setting something in the environment ?
There are no options to get Splus behaviour here, but I think you'll get what you want with this code: badindices<-sapply(tempdata,function(x)(bdind<-which(is.na(x)))[1]) I'm not sure why you're creating the bdind variable; you could get the same thing in badindices without that side effect with the simpler badindices<-sapply(tempdata,function(x) which(is.na(x))[1]) Duncan Murdoch ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html