1

I have the following function in R:

n<- function(theta){
d=theta[1]
z=theta[2]
Nh= c(1819, 1018)
N= sum(Nh)
sigmah= c(0.013, 0.0155)
n=sum(Nh*sigmah)^2/(N^2*d^2/z^2+sum(Nh*sigmah^2))
return(n)
} 

I would like to plot the function n over a range of inputs for d and z. How could I do this? Thanks

khmac21
  • 11
  • 1
  • 2
  • try `curve3d` from the `emdbook` package? – Ben Bolker Jan 31 '15 at 13:40
  • @BondedDust: http://stackoverflow.com/questions/11875941/3d-equivalent-of-the-curve-function-in-r feels like a better match to this question – Ben Bolker Jan 31 '15 at 16:07
  • There are of course many ways to represent data in a third dimension. `lattice::contourplot` (illustrated in the example offered as a duplicate), lattice::levelplot`, and the methods available in package:rgl in addition to the curve3d method mentioned by Ben. – IRTFM Jan 31 '15 at 16:08
  • @BenBolker: If you will then vote to close on that basis I can retract my close vote, but it's not possible to modify a close vote. – IRTFM Jan 31 '15 at 16:12

1 Answers1

2

I don't know what range of values is appropriate, but this produces something not too crazy:

library("emdbook")
curve3d(n(c(x,y)),xlim=c(1,2),ylim=c(1,2))
Ben Bolker
  • 211,554
  • 25
  • 370
  • 453