[R] code for power and suffix for x,y labels in plot( ).

Joshua Wiley jwiley.psych at gmail.com
Wed Jun 2 18:15:40 CEST 2010


On Tue, Jun 1, 2010 at 9:59 PM, Shant Ch <sha1one at yahoo.com> wrote:
> Hi
>
> I was trying to have a graph whose axes are X axis: m, Y axis: var[X ((a,b) in suffix, and (n,d) in the power)].
>
> X ((a,b) in suffix, and (n,d) in the power)-        X^(n,d) _ (a,b).
>
> Actually I require many plots involving different values of a,b,n,d, so need to keep this complicated notation.
> The expression() didn't work out for this case. Can anyone help me out.
> Thanks, in advance.
> Shant
>
>
>
>
>
>
> uniroot(function(x) x*(3^x)*log(4)-x*log(4/3)-(3^x)+1, lower = -2, upper = 2, tol = 0.001 )
>
> While using this I am getting the following error. Can anyone please help me out.
> Error in uniroot(function(x) x * (3^x) * log(4) - x * log(4/3) - (3^x) +  :   f() values at end points not of opposite sign.

Here is your function:

temp.fun <- function(x) {
  value <- x*(3^x)*log(4)-x*log(4/3)-(3^x)+1
  return(value)
}

look what happens when you do:

temp.fun(-2)
temp.fun(2)

in both cases, it returns a positive value.  uniroot() requires "The
function values at the endpoints must be of opposite signs (or zero)",
hence the error.  I believe your function has a lower bound of 0,
which is obtained when the input is 0.  So one option would be to
change your argument to uniroot() so that lower=0.  Although the
results are not particularly interesting in this case.

uniroot(function(x) x*(3^x)*log(4)-x*log(4/3)-(3^x)+1, lower = 0,
upper = 2, tol = 0.001 )

HTH,

Josh

>
> Thanks in advance.
>
> Shant
>
>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
>



-- 
Joshua Wiley
Senior in Psychology
University of California, Riverside
http://www.joshuawiley.com/



More information about the R-help mailing list