Peter Lauren wrote:
> 
> I obtain the coefficients of a nonlinear function
> thus.
> ------------------------------------------
> m=nls(y ~ a + b*x + c*x^2 + d*x^3 +
> e*exp(x)+f*log(x)+g*log2(x), start = list(a = 0, b =
> 1, c = 1, d=1, e=1, f=1, g=1))
> 
> c=coef(m)
> -------------------------------------------
> 
> However, when I look at c[1], I get something like
> a
> 2.345678
> 
> How can I extract 2.345678 as a number?
> 
> 

  It is a number, it just has a name... you should
be able to treat it just like any other numeric vector.
If you must you can remove the name by setting
names(c) <- NULL

> z = 2.345678
> names(z) = "a"
> z
       a 
2.345678 
> names(z)=NULL
> z
[1] 2.345678

-- 
View this message in context: 
http://www.nabble.com/Extracting-Number-from-Output-of-Coef%28%29-tf4787225.html#a13695243
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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.

Reply via email to