Quantcast

incomplete final line found warning

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

incomplete final line found warning

Xiaobo.Gu
Hi,

I saved the following as a UTF-8 encoded file named amberutil.r

as.factor.loop <- function(df, cols){

        if (!is.null(df) && !is.null(cols) && length(cols) > 0)
        {
                for(col in cols)
    {
                        df[[col]] <- as.factor(df[[col]])
                }
        }
  df
}

And got this warning message,

> source('D:/ambertuil.r')
Warning message:
In readLines(file) : incomplete final line found on 'D:/ambertuil.r'

Can you help with this?

Regards,

Xiaobo Gu

______________________________________________
[hidden email] 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 | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: incomplete final line found warning

David Winsemius

On Dec 10, 2011, at 10:01 PM, Xiaobo Gu wrote:

> Hi,
>
> I saved the following as a UTF-8 encoded file named amberutil.r
>
> as.factor.loop <- function(df, cols){
>
> if (!is.null(df) && !is.null(cols) && length(cols) > 0)
> {
> for(col in cols)
>    {
> df[[col]] <- as.factor(df[[col]])
> }
> }
>  df
> }
>
> And got this warning message,
>
>> source('D:/ambertuil.r')
> Warning message:
> In readLines(file) : incomplete final line found on 'D:/ambertuil.r'
>
> Can you help with this?

Help with what? You got a warning. And it had information that should  
tell you how to edit the file if the warning bothers you.

>

--

David Winsemius, MD
West Hartford, CT

______________________________________________
[hidden email] 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 | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: incomplete final line found warning

Prof Brian Ripley
On Sun, 11 Dec 2011, David Winsemius wrote:

>
> On Dec 10, 2011, at 10:01 PM, Xiaobo Gu wrote:

without following the posting guide in several respects and hence
leaving us guessing ....

>> Hi,
>>
>> I saved the following as a UTF-8 encoded file named amberutil.r

BTW, it is hard to know how you know that ASCII is encoded as UTF-8,
and on Windows (which from the file path it appears to be) it would
not have worked had it been UTF-8 encoded.  Let's hope this did not
mean what Windows calls 'Unicode', that is UTF-16LE.

>>
>> as.factor.loop <- function(df, cols){
>>
>> if (!is.null(df) && !is.null(cols) && length(cols) > 0)
>> {
>> for(col in cols)
>>   {
>> df[[col]] <- as.factor(df[[col]])
>> }
>> }
>> df
>> }
>>
>> And got this warning message,
>>
>>> source('D:/ambertuil.r')
>> Warning message:
>> In readLines(file) : incomplete final line found on 'D:/ambertuil.r'
>>
>> Can you help with this?
>
> Help with what? You got a warning. And it had information that should tell
> you how to edit the file if the warning bothers you.

Also, we were not told the version of R.  Updating (as requested by
the posting guide prior to posting) would most likely remove the
harmless warning (AFAIK it occurs only in 2.14.0 and not in
R-patched) if this were an ASCII file.

--
Brian D. Ripley,                  [hidden email]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
[hidden email] 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 | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: incomplete final line found warning

Xiaobo.Gu
On Sun, Dec 11, 2011 at 5:03 PM, Prof Brian Ripley
<[hidden email]> wrote:

> On Sun, 11 Dec 2011, David Winsemius wrote:
>
>>
>> On Dec 10, 2011, at 10:01 PM, Xiaobo Gu wrote:
>
>
> without following the posting guide in several respects and hence leaving us
> guessing ....
>
>
>>> Hi,
>>>
>>> I saved the following as a UTF-8 encoded file named amberutil.r
>
>
> BTW, it is hard to know how you know that ASCII is encoded as UTF-8, and on
> Windows (which from the file path it appears to be) it would not have worked
> had it been UTF-8 encoded.  Let's hope this did not mean what Windows calls
> 'Unicode', that is UTF-16LE.

I use RStudio to edit the source file, there is as save as encoding
option, and I chose UTF-8

>
>>>
>>> as.factor.loop <- function(df, cols){
>>>
>>>        if (!is.null(df) && !is.null(cols) && length(cols) > 0)
>>>        {
>>>                for(col in cols)
>>>  {
>>>                        df[[col]] <- as.factor(df[[col]])
>>>                }
>>>        }
>>> df
>>> }
>>>
>>> And got this warning message,
>>>
>>>> source('D:/ambertuil.r')
>>>
>>> Warning message:
>>> In readLines(file) : incomplete final line found on 'D:/ambertuil.r'
>>>
>>> Can you help with this?
>>
>>
>> Help with what? You got a warning. And it had information that should tell
>> you how to edit the file if the warning bothers you.

Can you help finding the reason about this warning.

>
>
> Also, we were not told the version of R.  Updating (as requested by the
> posting guide prior to posting) would most likely remove the harmless
> warning (AFAIK it occurs only in 2.14.0 and not in R-patched) if this were
> an ASCII file.

I am using R 2.14.0 64 bit on Windows.

>
> --
> Brian D. Ripley,                  [hidden email]
> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
> University of Oxford,             Tel:  +44 1865 272861 (self)
> 1 South Parks Road,                     +44 1865 272866 (PA)
> Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
[hidden email] 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 | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: incomplete final line found warning

Berend Hasselman
In reply to this post by Xiaobo.Gu
Xiaobo.Gu wrote
Hi,

I saved the following as a UTF-8 encoded file named amberutil.r

as.factor.loop <- function(df, cols){

        if (!is.null(df) && !is.null(cols) && length(cols) > 0)
        {
                for(col in cols)
    {
                        df[[col]] <- as.factor(df[[col]])
                }
        }
  df
}

And got this warning message,

> source('D:/ambertuil.r')
Warning message:
In readLines(file) : incomplete final line found on 'D:/ambertuil.r'

Can you help with this?
A warning message such as this could not be clearer.
It means that the last line of the file does not end with a <newline> sequence ==> the final line of the file is incomplete.

In an editor go to the end of that line and press <Enter> or <Return>
And save.

Alternatively configure your editor to always terminate the last line of a file with  a <newline> sequence.

/Berend
Loading...