On 06/03/2012 17:53, Federico Calboli wrote:> Hi All,
>
> I am writing a function that reads a file in
>
> myfile = file('myfile.raw', 'rb')
> .
> .
> .
> .
> .
> close(myfile)
>
> No matter what, I get the warning
>
> Warning message:
> closing unused connection 3 (myfile.raw)
>
> Since the whole thing is in a function, I'd like to avoid unecessary
noise for the user, and I'd like to kill the warning -- without having to
mess with global options.
>
> Any ideas how?
Make sure the connection (not 'file') is really closed. That message
indicates that close(myfile) was never called.
A good way to do this is to use on.exit() in your function.
> BW
>
> F
>
>
>
> --
> Federico C. F. Calboli
> Neuroepidemiology and Ageing Research
> Imperial College, St. Mary's Campus
> Norfolk Place, London W2 1PG
>
> Tel +44 (0)20 75941602 Fax +44 (0)20 75943193
>
> f.calboli [.a.t] imperial.ac.uk
> f.calboli [.a.t] gmail.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.
Hmm, how long have you been asking questions here? Following the
posting guide is way overdue. We should not have to guess what error
you made in the code you failed to show us.