[R] Simple question regarding domain restrictions/piecewise functions in R

chad.mills chad.mills at gmail.com
Mon Mar 26 17:28:30 CEST 2012


Yes!  Thanks.  It was just the "NA" value instead of the "as.null" that does
the trick.  Correct code for the original piecewise I stated (for those who
might be looking later) is:

f <- function(x){ 
                 ifelse((-1 < x & x < 1),x^2,ifelse((2<x&x<3),1,NA)) 
            } 
 plot(f,xlim=c(-1,3)) 

-Chad Mills

--
View this message in context: http://r.789695.n4.nabble.com/Simple-question-regarding-domain-restrictions-piecewise-functions-in-R-tp4504199p4506155.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list