#5069 that gdata:::write.fwf
ended up with error (at times) when the argument is a data.table is now fixed in v1.8.11.
To summarise the issue, when [.data.table
is called from within a function (here write.fwf
) in a package, it tries to identify if the package is data.table aware, and if not (in this case, it's not), it calls the equivalent [.data.frame
method. And in your case, that lead to a character vector. And the next line called for a setkey
operation on a vector (to set the key to NULL).
A simple fix was to check if the output from [.data.frame
is still a data.table
and if so set the key to NULL.
Thanks again for reporting.