Formatting column displays

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Formatting column displays

Bruce Ratner PhD
R-helpers:
I need some references for formatting the display of my data frame columns.
Any guidance will be appreciated. Bruce
~~
I have a date frame with one column as an integer for which I want a comma display,
one column consisting of dollar amounts, one column for which I want a display to two digits after the decimal point, and one column as integers ranging between
100 - 999.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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: Formatting column displays

Ulrik Stervbo-2
Hi Bruce,

display as in the console or as a table for presentation?

For the latter, look at sprintf:

sprintf("%,1f", 1)
sprintf("%.2f", 2.5678)
sprintf("$%.3f", 2.5678)

HTH
Ulrik

On Fri, 5 May 2017 at 14:08 Bruce Ratner PhD <[hidden email]> wrote:

> R-helpers:
> I need some references for formatting the display of my data frame columns.
> Any guidance will be appreciated. Bruce
> ~~
> I have a date frame with one column as an integer for which I want a comma
> display,
> one column consisting of dollar amounts, one column for which I want a
> display to two digits after the decimal point, and one column as integers
> ranging between
> 100 - 999.
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> 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.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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: Formatting column displays

Jeff Newmiller
In reply to this post by Bruce Ratner PhD
Data frames are primarily data storage objects, not data display objects. You can create a separate version of your data frame with formatted text strings, but what you usually really want is to handle column alignment as well and that really has to be addressed as part of your data output process, which you have said nothing about.

Do you know about HTML or markdown or LaTeX? These are useful formats for creating reproducible research, and they are well supported through the knitr package and in RStudio via Rnw and Rmd files. Tables in particular are well supported via LaTeX with the tables package.  The ReporteR package can output to Microsoft Word files directly with various formatting options, but it doesn't play well with the other tools.
--
Sent from my phone. Please excuse my brevity.

On May 5, 2017 5:08:19 AM PDT, Bruce Ratner PhD <[hidden email]> wrote:

>R-helpers:
>I need some references for formatting the display of my data frame
>columns.
>Any guidance will be appreciated. Bruce
>~~
>I have a date frame with one column as an integer for which I want a
>comma display,
>one column consisting of dollar amounts, one column for which I want a
>display to two digits after the decimal point, and one column as
>integers ranging between
>100 - 999.
>
>______________________________________________
>[hidden email] mailing list -- To UNSUBSCRIBE and more, see
>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 -- To UNSUBSCRIBE and more, see
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: Formatting column displays

Bruce Ratner PhD
In reply to this post by Ulrik Stervbo-2
Ulrik: Thanks for reply. I obviously new to R, so I feel if the output on the console looks right I'm half way through my problem. I know it's not WYSIWYG, but it's a quasi start.
Thanks.
Bruce

______________



> On May 5, 2017, at 8:56 AM, Ulrik Stervbo <[hidden email]> wrote:
>
> Hi Bruce,
>
> display as in the console or as a table for presentation?
>
> For the latter, look at sprintf:
>
> sprintf("%,1f", 1)
> sprintf("%.2f", 2.5678)
> sprintf("$%.3f", 2.5678)
>
> HTH
> Ulrik
>
>> On Fri, 5 May 2017 at 14:08 Bruce Ratner PhD <[hidden email]> wrote:
>> R-helpers:
>> I need some references for formatting the display of my data frame columns.
>> Any guidance will be appreciated. Bruce
>> ~~
>> I have a date frame with one column as an integer for which I want a comma display,
>> one column consisting of dollar amounts, one column for which I want a display to two digits after the decimal point, and one column as integers ranging between
>> 100 - 999.
>>
>> ______________________________________________
>> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
>> 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.

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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: Formatting column displays

Bruce Ratner PhD
In reply to this post by Jeff Newmiller
Jeff: Thanks for reply. I will follow your lead.
Thanks.
Bruce

______________



> On May 5, 2017, at 9:15 AM, Jeff Newmiller <[hidden email]> wrote:
>
> Data frames are primarily data storage objects, not data display objects. You can create a separate version of your data frame with formatted text strings, but what you usually really want is to handle column alignment as well and that really has to be addressed as part of your data output process, which you have said nothing about.
>
> Do you know about HTML or markdown or LaTeX? These are useful formats for creating reproducible research, and they are well supported through the knitr package and in RStudio via Rnw and Rmd files. Tables in particular are well supported via LaTeX with the tables package.  The ReporteR package can output to Microsoft Word files directly with various formatting options, but it doesn't play well with the other tools.
> --
> Sent from my phone. Please excuse my brevity.
>
>> On May 5, 2017 5:08:19 AM PDT, Bruce Ratner PhD <[hidden email]> wrote:
>> R-helpers:
>> I need some references for formatting the display of my data frame
>> columns.
>> Any guidance will be appreciated. Bruce
>> ~~
>> I have a date frame with one column as an integer for which I want a
>> comma display,
>> one column consisting of dollar amounts, one column for which I want a
>> display to two digits after the decimal point, and one column as
>> integers ranging between
>> 100 - 999.
>>
>> ______________________________________________
>> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
>> 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 -- To UNSUBSCRIBE and more, see
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: Formatting column displays

Ulrik Stervbo-2
Hi Bruce,

while working with data I would not touch the formatting of the columns. If
knowing the units is important, you can add it to the column name rather
than the values of the columns.

For presentation purposes - where everything is turned into strings - it is
a different story. Once you are done with your calculations, you can format
everything the way you like it. I find kable() from the knitr package to
help a lot with basic formatting, though you might have to do a little
pre-processing by hand (and here sprintf comes in handy).

And to echo Jeff: you should use Rmarkdown if you are writing up reports
and it is well integrated with Rstudio. knitr works behind the scenes, and
I believe it can even create a Microsoft Word document though pandoc,
without the need for ReporteR (but I have never tried, so I might be wrong).

Best,
Ulrik

On Fri, 5 May 2017 at 15:26 Bruce Ratner PhD <[hidden email]> wrote:

> Jeff: Thanks for reply. I will follow your lead.
> Thanks.
> Bruce
>
> ______________
>
>
>
> > On May 5, 2017, at 9:15 AM, Jeff Newmiller <[hidden email]>
> wrote:
> >
> > Data frames are primarily data storage objects, not data display
> objects. You can create a separate version of your data frame with
> formatted text strings, but what you usually really want is to handle
> column alignment as well and that really has to be addressed as part of
> your data output process, which you have said nothing about.
> >
> > Do you know about HTML or markdown or LaTeX? These are useful formats
> for creating reproducible research, and they are well supported through the
> knitr package and in RStudio via Rnw and Rmd files. Tables in particular
> are well supported via LaTeX with the tables package.  The ReporteR package
> can output to Microsoft Word files directly with various formatting
> options, but it doesn't play well with the other tools.
> > --
> > Sent from my phone. Please excuse my brevity.
> >
> >> On May 5, 2017 5:08:19 AM PDT, Bruce Ratner PhD <[hidden email]> wrote:
> >> R-helpers:
> >> I need some references for formatting the display of my data frame
> >> columns.
> >> Any guidance will be appreciated. Bruce
> >> ~~
> >> I have a date frame with one column as an integer for which I want a
> >> comma display,
> >> one column consisting of dollar amounts, one column for which I want a
> >> display to two digits after the decimal point, and one column as
> >> integers ranging between
> >> 100 - 999.
> >>
> >> ______________________________________________
> >> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> >> 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 -- To UNSUBSCRIBE and more, see
> 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.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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: Formatting column displays

Bruce Ratner PhD
Ulrike: Thanks for the afterthought.
I'll let you know if I'm successful.
Thanks, again.
Bruce

______________




> On May 5, 2017, at 10:55 AM, Ulrik Stervbo <[hidden email]> wrote:
>
> Hi Bruce,
>
> while working with data I would not touch the formatting of the columns. If knowing the units is important, you can add it to the column name rather than the values of the columns.
>
> For presentation purposes - where everything is turned into strings - it is a different story. Once you are done with your calculations, you can format everything the way you like it. I find kable() from the knitr package to help a lot with basic formatting, though you might have to do a little pre-processing by hand (and here sprintf comes in handy).
>
> And to echo Jeff: you should use Rmarkdown if you are writing up reports and it is well integrated with Rstudio. knitr works behind the scenes, and I believe it can even create a Microsoft Word document though pandoc, without the need for ReporteR (but I have never tried, so I might be wrong).
>
> Best,
> Ulrik
>
>> On Fri, 5 May 2017 at 15:26 Bruce Ratner PhD <[hidden email]> wrote:
>> Jeff: Thanks for reply. I will follow your lead.
>> Thanks.
>> Bruce
>>
>> ______________
>>
>>
>>
>> > On May 5, 2017, at 9:15 AM, Jeff Newmiller <[hidden email]> wrote:
>> >
>> > Data frames are primarily data storage objects, not data display objects. You can create a separate version of your data frame with formatted text strings, but what you usually really want is to handle column alignment as well and that really has to be addressed as part of your data output process, which you have said nothing about.
>> >
>> > Do you know about HTML or markdown or LaTeX? These are useful formats for creating reproducible research, and they are well supported through the knitr package and in RStudio via Rnw and Rmd files. Tables in particular are well supported via LaTeX with the tables package.  The ReporteR package can output to Microsoft Word files directly with various formatting options, but it doesn't play well with the other tools.
>> > --
>> > Sent from my phone. Please excuse my brevity.
>> >
>> >> On May 5, 2017 5:08:19 AM PDT, Bruce Ratner PhD <[hidden email]> wrote:
>> >> R-helpers:
>> >> I need some references for formatting the display of my data frame
>> >> columns.
>> >> Any guidance will be appreciated. Bruce
>> >> ~~
>> >> I have a date frame with one column as an integer for which I want a
>> >> comma display,
>> >> one column consisting of dollar amounts, one column for which I want a
>> >> display to two digits after the decimal point, and one column as
>> >> integers ranging between
>> >> 100 - 999.
>> >>
>> >> ______________________________________________
>> >> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
>> >> 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 -- To UNSUBSCRIBE and more, see
>> 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.

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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: Formatting column displays

Bruce Ratner PhD
In reply to this post by Jeff Newmiller
Jeff:
I cannot install the ReporteR package. Is there a work-around, or is the
error message correct?
Thanks. Bruce

R> install.packages("ReporteR") Installing package into
‘C:/Users/BruceRatner/Documents/R/win-library/3.3’ (as ‘lib’ is
unspecified) Warning in install.packages :
   package ‘ReporteR’ is not available (for R version 3.3.3)


 

Jeff Newmiller wrote:
> Data frames are primarily data storage objects, not data display objects. You can create a separate version of your data frame with formatted text strings, but what you usually really want is to handle column alignment as well and that really has to be addressed as part of your data output process, which you have said nothing about.
>
> Do you know about HTML or markdown or LaTeX? These are useful formats for creating reproducible research, and they are well supported through the knitr package and in RStudio via Rnw and Rmd files. Tables in particular are well supported via LaTeX with the tables package.  The ReporteR package can output to Microsoft Word files directly with various formatting options, but it doesn't play well with the other tools.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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: Formatting column displays

R help mailing list-2
Use Google: a search for "R Reporter package" shows that the package is
named "ReporteRs".

Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Fri, May 5, 2017 at 2:50 PM, BR_email <[hidden email]> wrote:

> Jeff:
> I cannot install the ReporteR package. Is there a work-around, or is the
> error message correct?
> Thanks. Bruce
>
> R> install.packages("ReporteR") Installing package into
> ‘C:/Users/BruceRatner/Documents/R/win-library/3.3’ (as ‘lib’ is
> unspecified) Warning in install.packages :
>   package ‘ReporteR’ is not available (for R version 3.3.3)
>
>
>
> Jeff Newmiller wrote:
>
>> Data frames are primarily data storage objects, not data display objects.
>> You can create a separate version of your data frame with formatted text
>> strings, but what you usually really want is to handle column alignment as
>> well and that really has to be addressed as part of your data output
>> process, which you have said nothing about.
>>
>> Do you know about HTML or markdown or LaTeX? These are useful formats for
>> creating reproducible research, and they are well supported through the
>> knitr package and in RStudio via Rnw and Rmd files. Tables in particular
>> are well supported via LaTeX with the tables package.  The ReporteR package
>> can output to Microsoft Word files directly with various formatting
>> options, but it doesn't play well with the other tools.
>>
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posti
> ng-guide.html
> and provide commented, minimal, self-contained, reproducible code.

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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: Formatting column displays

Bruce Ratner PhD
Thanks, Bill.
Bruce

______________




> On May 5, 2017, at 5:54 PM, William Dunlap <[hidden email]> wrote:
>
> Use Google: a search for "R Reporter package" shows that the package is named "ReporteRs".
>
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
>
>> On Fri, May 5, 2017 at 2:50 PM, BR_email <[hidden email]> wrote:
>> Jeff:
>> I cannot install the ReporteR package. Is there a work-around, or is the error message correct?
>> Thanks. Bruce
>>
>> R> install.packages("ReporteR") Installing package into ‘C:/Users/BruceRatner/Documents/R/win-library/3.3’ (as ‘lib’ is unspecified) Warning in install.packages :
>>   package ‘ReporteR’ is not available (for R version 3.3.3)
>>
>>
>>  
>> Jeff Newmiller wrote:
>>> Data frames are primarily data storage objects, not data display objects. You can create a separate version of your data frame with formatted text strings, but what you usually really want is to handle column alignment as well and that really has to be addressed as part of your data output process, which you have said nothing about.
>>>
>>> Do you know about HTML or markdown or LaTeX? These are useful formats for creating reproducible research, and they are well supported through the knitr package and in RStudio via Rnw and Rmd files. Tables in particular are well supported via LaTeX with the tables package.  The ReporteR package can output to Microsoft Word files directly with various formatting options, but it doesn't play well with the other tools.
>>
>> ______________________________________________
>> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
>> 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.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.