[R] Export nls object to text file

R. Michael Weylandt michael.weylandt at gmail.com
Wed Feb 29 13:15:10 CET 2012


You can save it as an R Data file using save() and then reload it with
load() -- there's not a natural way to make it something that lives
nicely in a text file (since an nls object is quite complex) -- if you
are just going to be using the object again in R I'd recommend the
first. If you need it in some other program can you at least identify
which attributes you need? sink() will also be of help (in conjunction
with various print methods)

Michael

On Wed, Feb 29, 2012 at 4:27 AM, Sarah84 <gabriel.soderberg at gmail.com> wrote:
> Hi all,
>
> I am new to R and have some trouble with exporting results from a non linear
> squares object (.nls), would be very thankful if anyone could help me.
>
> So what I'm doing is a Bass modelling of some data. The result is stored in
> the object "Bass.nls". I want to  export a matrix with the three columns:
> observation number, actual observation value, predicted observation value.
> Can I do this somehow? If not can I export the full nls object somehow? When
> trying the to export using,
>
> write.table(Bass.nls)
>
> I get the following error message:
>
> Error in as.data.frame.default(x[[i]], optional = TRUE, stringsAsFactors =
> stringsAsFactors) :
>  cannot coerce class '"nls"' into a data.frame
>
> I am thankful for all help I can get!
>
> Sincerely yours
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Export-nls-object-to-text-file-tp4431039p4431039.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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