[R] Finding a scalar value...
Petar Milin
pmilin at ff.uns.ac.rs
Mon Aug 16 14:19:51 CEST 2010
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 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.
>
>
More information about the R-help
mailing list