Re: [R] Finding a scalar value...

2010-08-19 Thread Adaikalavan Ramasamy

Your best option is to read the relevant help files.

A simple (untested) example to find R when P, T and scal.fn=Z is given, 
is to do this:


 my.fun - function(P, R, T, Z) scal.fn(P, R, T) - Z
 uniroot( fn, R=rr, T=tt, Z=zz, lower=-100, upper=100 )$root

You have to make an intelligent guess on the upper and lower ranges for 
the parameter R. I have used +/- 1 million as a silly example.


HOWEVER, I do not think this works when P,R,T,Z are scalars. Try it to 
be sure. If not, then you may have to write a for or apply loop.


Regards, Adai




On 16/08/2010 13:19, Petar Milin wrote:

Thanks for the answer!
However, if I would have scal.fn() like below, how would I apply
uniroot() or optimize() or the like?

Best,
PM

On 16/08/10 13:24, Adaikalavan Ramasamy wrote:

You probably need to look up on how to write functions.

Try

  scal.fn- function(P, R, T){
   out- ( 1/R - T ) / ( P - T )
   return(out)
  }

Here is a fake example:

  df- cbind.data.frame( P=rnorm(10), R=rnorm(10), T=rnorm(10) )
  scal.fn( df$P, df$R, df$T )

Or are you trying to solve other parameters given scal values? If so,
try having a look at functions like uniroot().

Regards, Adai


On 16/08/2010 11:48, Petar Milin wrote:

Hello!
I need to find a simple scalar value:
Scal = ((1/R) - T) / (P - T),
where R, T, and P are vectors in a data.frame.

Please, can anyone tell me how to solve that in R?

Best,
PM

__
R-help@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.





__
R-help@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.


Re: [R] Finding a scalar value...

2010-08-16 Thread Adaikalavan Ramasamy

You probably need to look up on how to write functions.

Try

 scal.fn - function(P, R, T){
  out - ( 1/R - T ) / ( P - T )
  return(out)
 }

Here is a fake example:

 df - cbind.data.frame( P=rnorm(10), R=rnorm(10), T=rnorm(10) )
 scal.fn( df$P, df$R, df$T )

Or are you trying to solve other parameters given scal values? If so, 
try having a look at functions like uniroot().


Regards, Adai


On 16/08/2010 11:48, Petar Milin wrote:

Hello!
I need to find a simple scalar value:
Scal = ((1/R) - T) / (P - T),
where R, T, and P are vectors in a data.frame.

Please, can anyone tell me how to solve that in R?

Best,
PM

__
R-help@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.


__
R-help@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.


Re: [R] Finding a scalar value...

2010-08-16 Thread Petar Milin

Thanks for the answer!
However, if I would have scal.fn() like below, how would I apply 
uniroot() or optimize() or the like?


Best,
PM

On 16/08/10 13:24, Adaikalavan Ramasamy wrote:

You probably need to look up on how to write functions.

Try

 scal.fn - function(P, R, T){
  out - ( 1/R - T ) / ( P - T )
  return(out)
 }

Here is a fake example:

 df - cbind.data.frame( P=rnorm(10), R=rnorm(10), T=rnorm(10) )
 scal.fn( df$P, df$R, df$T )

Or are you trying to solve other parameters given scal values? If so, 
try having a look at functions like uniroot().


Regards, Adai


On 16/08/2010 11:48, Petar Milin wrote:

Hello!
I need to find a simple scalar value:
Scal = ((1/R) - T) / (P - T),
where R, T, and P are vectors in a data.frame.

Please, can anyone tell me how to solve that in R?

Best,
PM

__
R-help@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.





__
R-help@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.