a query regarding plotting piece-wise function in r -
i graph following piece-wise function in r having trouble defining it. define following function.it takes value 0.31 x between 0 , less 10 , x between 10 , 29, takes value 0.31-0.00017397(x-10) , x greater 29. below r code.
f <- function(x){ ifelse((0 < x & x < 10),0.31,ifelse((10<= x & x < 29),(0.31-0.00017397(x-10)),ifelse((29<=x),(0.31-0.00052702(x-29)),na))) } plot(f,xlim=c(0,35))
many in advance!
this works me:
f <- function(x){ ifelse((0 < x & x < 10),0.31,ifelse((10 <= x & x < 29),(0.31-0.00017397*(x-10)),ifelse((29 <= x),(0.31-0.00052702*(x-29)),na))) } plot(f,xlim=c(0,35))
(note * multiplication)
Comments
Post a Comment