Simple cat statement - output truncated

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Simple cat statement - output truncated

rkevinburton
I have a statement:

    cat("myforecast ETS(", paste(object$components[1], object$components[2], object$components[3], object$components[4], sep = ","), ") ", n, "\n")

That generates:

cast ETS( A,N,N,FALSE )  3

Anyone guess as to why the first 5 letters are truncated/missing?

Kevin

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

Re: Simple cat statement - output truncated

Duncan Murdoch
On 7/15/2009 9:53 AM, [hidden email] wrote:
> I have a statement:
>
>     cat("myforecast ETS(", paste(object$components[1], object$components[2], object$components[3], object$components[4], sep = ","), ") ", n, "\n")
>
> That generates:
>
> cast ETS( A,N,N,FALSE )  3
>
> Anyone guess as to why the first 5 letters are truncated/missing?

You are probably being punished for posting non-reproducible code*.

When I try a reproducible version of the line above, things look fine:

 > cat("myforecast ETS(", paste("A","N","N",FALSE, sep = ","), ") ", 3,
"\n")
myforecast ETS( A,N,N,FALSE )  3


Duncan Murdoch

* R has a new predictive punishment module.  It punishes you for things
it knows you will do later.

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

Re: Simple cat statement - output truncated

rkevinburton
So then I am to assume that the output of 'cat' can be truncated by passing it "bad" arrays. That is the only difference between the "reproducible" code you show and mine. It is just a theory but say that the components array is not dimmensioned for 4 elements. It seems a little strange if that is the case that a reference error is not thrown and just the output of the cat call is affected.

Kevin

---- Duncan Murdoch <[hidden email]> wrote:

> On 7/15/2009 9:53 AM, [hidden email] wrote:
> > I have a statement:
> >
> >     cat("myforecast ETS(", paste(object$components[1], object$components[2], object$components[3], object$components[4], sep = ","), ") ", n, "\n")
> >
> > That generates:
> >
> > cast ETS( A,N,N,FALSE )  3
> >
> > Anyone guess as to why the first 5 letters are truncated/missing?
>
> You are probably being punished for posting non-reproducible code*.
>
> When I try a reproducible version of the line above, things look fine:
>
>  > cat("myforecast ETS(", paste("A","N","N",FALSE, sep = ","), ") ", 3,
> "\n")
> myforecast ETS( A,N,N,FALSE )  3
>
>
> Duncan Murdoch
>
> * R has a new predictive punishment module.  It punishes you for things
> it knows you will do later.

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

Re: Simple cat statement - output truncated

Duncan Murdoch
On 7/16/2009 10:21 AM, [hidden email] wrote:
> So then I am to assume that the output of 'cat' can be truncated by passing it "bad" arrays.

I certainly wouldn't draw that conclusion.  Without a reproducible
example, my assumption would be that it is unrelated to cat().

Duncan Murdoch

> That is the only difference between the "reproducible" code you show and mine. It is just a theory but say that the components array is not dimmensioned for 4 elements. It seems a little strange if that is the case that a reference error is not thrown and just the output of the cat call is affected.
>
> Kevin
>
> ---- Duncan Murdoch <[hidden email]> wrote:
>> On 7/15/2009 9:53 AM, [hidden email] wrote:
>> > I have a statement:
>> >
>> >     cat("myforecast ETS(", paste(object$components[1], object$components[2], object$components[3], object$components[4], sep = ","), ") ", n, "\n")
>> >
>> > That generates:
>> >
>> > cast ETS( A,N,N,FALSE )  3
>> >
>> > Anyone guess as to why the first 5 letters are truncated/missing?
>>
>> You are probably being punished for posting non-reproducible code*.
>>
>> When I try a reproducible version of the line above, things look fine:
>>
>>  > cat("myforecast ETS(", paste("A","N","N",FALSE, sep = ","), ") ", 3,
>> "\n")
>> myforecast ETS( A,N,N,FALSE )  3
>>
>>
>> Duncan Murdoch
>>
>> * R has a new predictive punishment module.  It punishes you for things
>> it knows you will do later.

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

Re: Simple cat statement - output truncated

macrakis
In reply to this post by rkevinburton
Kevin,

The habitués of this mailing list get irritated when users mail in
problem reports which don't include enough information to reproduce
the problem, as requested in the standard footer of r-help mail
("PLEASE ... provide commented, minimal, self-contained, reproducible
code.") This irritation is sometimes expressed aggressively and
sometimes humorously. Be thankful that you drew "humorously".

So... please provide minimal, self-contained code that allows us to
reproduce your problem.  What is meant by "self-contained"?  It is
code that if you type it in to a fresh R, elicits your problem.  This
includes setting any necessary variables to appropriate values etc.

            -s

On Thu, Jul 16, 2009 at 10:21 AM, <[hidden email]> wrote:

>
> So then I am to assume that the output of 'cat' can be truncated by passing it "bad" arrays. That is the only difference between the "reproducible" code you show and mine. It is just a theory but say that the components array is not dimmensioned for 4 elements. It seems a little strange if that is the case that a reference error is not thrown and just the output of the cat call is affected.
>
> Kevin
>
> ---- Duncan Murdoch <[hidden email]> wrote:
> > On 7/15/2009 9:53 AM, [hidden email] wrote:
> > > I have a statement:
> > >
> > >     cat("myforecast ETS(", paste(object$components[1], object$components[2], object$components[3], object$components[4], sep = ","), ") ", n, "\n")
> > >
> > > That generates:
> > >
> > > cast ETS( A,N,N,FALSE )  3
> > >
> > > Anyone guess as to why the first 5 letters are truncated/missing?
> >
> > You are probably being punished for posting non-reproducible code*.
> >
> > When I try a reproducible version of the line above, things look fine:
> >
> >  > cat("myforecast ETS(", paste("A","N","N",FALSE, sep = ","), ") ", 3,
> > "\n")
> > myforecast ETS( A,N,N,FALSE )  3
> >
> >
> > Duncan Murdoch
> >
> > * R has a new predictive punishment module.  It punishes you for things
> > it knows you will do later.
>
> ______________________________________________
> [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.

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

Re: Simple cat statement - output truncated

rkevinburton
In reply to this post by Duncan Murdoch
It has to be related to 'cat' because the output of 'cat' is truncated. I am just tyring to find out some possible reasons as to why it is truncated. I have been unable to form an array like is in the test program. Do you think there is something else that is gobbling up the output from cat that would make it appear to be truncated?

Kevin

---- Duncan Murdoch <[hidden email]> wrote:

> On 7/16/2009 10:21 AM, [hidden email] wrote:
> > So then I am to assume that the output of 'cat' can be truncated by passing it "bad" arrays.
>
> I certainly wouldn't draw that conclusion.  Without a reproducible
> example, my assumption would be that it is unrelated to cat().
>
> Duncan Murdoch
>
> > That is the only difference between the "reproducible" code you show and mine. It is just a theory but say that the components array is not dimmensioned for 4 elements. It seems a little strange if that is the case that a reference error is not thrown and just the output of the cat call is affected.
> >
> > Kevin
> >
> > ---- Duncan Murdoch <[hidden email]> wrote:
> >> On 7/15/2009 9:53 AM, [hidden email] wrote:
> >> > I have a statement:
> >> >
> >> >     cat("myforecast ETS(", paste(object$components[1], object$components[2], object$components[3], object$components[4], sep = ","), ") ", n, "\n")
> >> >
> >> > That generates:
> >> >
> >> > cast ETS( A,N,N,FALSE )  3
> >> >
> >> > Anyone guess as to why the first 5 letters are truncated/missing?
> >>
> >> You are probably being punished for posting non-reproducible code*.
> >>
> >> When I try a reproducible version of the line above, things look fine:
> >>
> >>  > cat("myforecast ETS(", paste("A","N","N",FALSE, sep = ","), ") ", 3,
> >> "\n")
> >> myforecast ETS( A,N,N,FALSE )  3
> >>
> >>
> >> Duncan Murdoch
> >>
> >> * R has a new predictive punishment module.  It punishes you for things
> >> it knows you will do later.
>

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

Re: Simple cat statement - output truncated

Don MacQueen
I suppose it's conceivable that your object named "object" has some
non-standard character(s) in it that cause the code underlying cat()
to do something weird. For example,

>  cat('abcdef','\r','\n')
  bcdef

Appears to truncate the first character.

Basic debugging suggests breaking down the problem expression into
its components in the hopes that the problem will manifest itself.
So, what happens if  you do just

   paste(object$components[1], object$components[2],
object$components[3], object$components[4], sep = ",")

Or simpler yet, what happens if you do each of these?

   cat(object$components[1],'\n')
   cat(object$components[2] ,'\n')
   cat(object$components[3] ,'\n')
   cat(object$components[4] ,'\n')

And are any of these very different if you use print() instead of
cat(), without the ,'\n', of course.

-Don

At 9:11 AM -0700 7/16/09, <[hidden email]> wrote:

>It has to be related to 'cat' because the output of 'cat' is
>truncated. I am just tyring to find out some possible reasons as to
>why it is truncated. I have been unable to form an array like is in
>the test program. Do you think there is something else that is
>gobbling up the output from cat that would make it appear to be
>truncated?
>
>Kevin
>
>---- Duncan Murdoch <[hidden email]> wrote:
>>  On 7/16/2009 10:21 AM, [hidden email] wrote:
>>  > So then I am to assume that the output of 'cat' can be truncated
>>by passing it "bad" arrays.
>>
>>  I certainly wouldn't draw that conclusion.  Without a reproducible
>>  example, my assumption would be that it is unrelated to cat().
>>
>>  Duncan Murdoch
>>
>>  > That is the only difference between the "reproducible" code you
>>show and mine. It is just a theory but say that the components
>>array is not dimmensioned for 4 elements. It seems a little strange
>>if that is the case that a reference error is not thrown and just
>>the output of the cat call is affected.
>>  >
>>  > Kevin
>>  >
>>  > ---- Duncan Murdoch <[hidden email]> wrote:
>>  >> On 7/15/2009 9:53 AM, [hidden email] wrote:
>>  >> > I have a statement:
>>  >> >
>>  >> >     cat("myforecast ETS(", paste(object$components[1],
>>object$components[2], object$components[3], object$components[4],
>>sep = ","), ") ", n, "\n")
>>  >> >
>>  >> > That generates:
>>  >> >
>>  >> > cast ETS( A,N,N,FALSE )  3
>>  >> >
>>  >> > Anyone guess as to why the first 5 letters are truncated/missing?
>>  >>
>>  >> You are probably being punished for posting non-reproducible code*.
>>  >>
>>  >> When I try a reproducible version of the line above, things look fine:
>>  >>
>>  >>  > cat("myforecast ETS(", paste("A","N","N",FALSE, sep = ","), ") ", 3,
>>  >> "\n")
>>  >> myforecast ETS( A,N,N,FALSE )  3
>>  >>
>>  >>
>>  >> Duncan Murdoch
>>  >>
>  > >> * R has a new predictive punishment module.  It punishes you for things
>  > >> it knows you will do later.
>  >
>
>______________________________________________
>[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.


--
--------------------------------------
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA
925-423-1062

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