Question

I want to replicate this figure in R, not the table that is just the data range and function information. The problem is with some of these functions, doing all of them in R. For example the inverse hyperbolic sine, ...?! Thank you

eq <- function(x) {arcsinh(x)}
tmp <- data.frame(x=1:50, y=eq(1:50))
p <- qplot(x, y, data=tmp, xlab="X-axis", ylab="Y-axis")
c <- stat_function(fun=eq)
print(p + c)

mathematical functions and their figures

Was it helpful?

Solution

Some of these are in base.

cosh(x)
sinh(x)
tanh(x)
acosh(x)
asinh(x)
atanh(x)

But this leaves out acsch(x), asech(x) and acoth(x). You can create these using log.

For example acsch(x) is equivalent to ln((1/x)+(sqrt(1+x^2)/abs(x))) , i.e

plot(log(1/((-100:100)/100)+sqrt(1+(((-100:100)/100))^2)/abs((-100:100)/100)))

The other two can be found here http://en.wikipedia.org/wiki/Hyperbolic_function

OTHER TIPS

There is no arcsinh function in base R:

?sinh   # note that the function name is `asinh`

This succeeds:

eq <- function(x) {asinh(x)}
tmp <- data.frame(x=1:50, y=eq(1:50))
p <- qplot(x, y, data=tmp, xlab="X-axis", ylab="Y-axis")
c <- stat_function(fun=eq)
print(p + c)

As would an effort with:

tmp <- data.frame(x=-50:50, y=eq(-50:50))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top