Hello dears How to write the following command in R If 1<x<2, f(x)=2*x+1, ifelse f(x)=0
1<x<2
f(x)=2*x+1
f(x)=0
Hi! I would use function() and ifelse()
function()
ifelse()
f<-function(x){ return(ifelse(1<x & x<2,2*x+1,0)) }
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed. If you have a query related to it or one of the replies, start a new topic and refer back with a link.