Wrap column headers caption

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

Wrap column headers caption

Felipe Carrillo
Hi:
Using this dataframe with quite long column headers, how can I wrap the
text so that the columns are narrower. I was trying to use strwrap without
success. Thanks

reportDF <- structure(list(IDDate = c("3/12/2010", "3/13/2010", "3/14/2010",
"3/15/2010"), FirstRunoftheYear = c("33 (119 ? 119)", "n (0 ? 0)", "893 (110 ?
146)",
"140 (111 ? 150)"), SecondRunoftheYear = c("33 (71 ? 71)", "n (0 ? 0)",
"337 (67 ? 74)", "140 (68 ? 84)"), ThirdRunoftheYear = c("890 (32 ? 47)",
"n (0 ? 0)", "10,602 (32 ? 52)", "2,635 (34 ? 66)"), FourthRunoftheYear = c("0 (
? )",
"n (0 ? 0)", "0 ( ? )", "0 ( ? )"), LastRunoftheYear = c("0 ( ? )", "n (0 ? 0)",
"0 ( ? )", "0 ( ? )")), .Names = c("IDDate", "First Run of the Year", "Second
Run of the Year",
"Third Run of the Year", "Fourth Run of the Year", "Last Run of the Year"),
row.names = c(NA, 4L), class = "data.frame")
 


Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish & Wildlife Service
California, USA




______________________________________________
[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: Wrap column headers caption

Henrique Dallazuanna
You can't try this:

sapply(names(reportDF), toString, width = 10)

abbreviate(names(reportDF))

On Tue, Jul 13, 2010 at 2:43 PM, Felipe Carrillo
<[hidden email]>wrote:

> Hi:
> Using this dataframe with quite long column headers, how can I wrap the
> text so that the columns are narrower. I was trying to use strwrap without
> success. Thanks
>
> reportDF <- structure(list(IDDate = c("3/12/2010", "3/13/2010",
> "3/14/2010",
> "3/15/2010"), FirstRunoftheYear = c("33 (119 ? 119)", "n (0 ? 0)", "893
> (110 ?
> 146)",
> "140 (111 ? 150)"), SecondRunoftheYear = c("33 (71 ? 71)", "n (0 ? 0)",
> "337 (67 ? 74)", "140 (68 ? 84)"), ThirdRunoftheYear = c("890 (32 ? 47)",
> "n (0 ? 0)", "10,602 (32 ? 52)", "2,635 (34 ? 66)"), FourthRunoftheYear =
> c("0 (
> ? )",
> "n (0 ? 0)", "0 ( ? )", "0 ( ? )"), LastRunoftheYear = c("0 ( ? )", "n (0 ?
> 0)",
> "0 ( ? )", "0 ( ? )")), .Names = c("IDDate", "First Run of the Year",
> "Second
> Run of the Year",
> "Third Run of the Year", "Fourth Run of the Year", "Last Run of the Year"),
> row.names = c(NA, 4L), class = "data.frame")
>
>
>
> Felipe D. Carrillo
> Supervisory Fishery Biologist
> Department of the Interior
> US Fish & Wildlife Service
> California, USA
>
>
>
>
> ______________________________________________
> [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.
>


--
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

        [[alternative HTML version deleted]]


______________________________________________
[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: Wrap column headers caption

Erik Iverson-3
In reply to this post by Felipe Carrillo

> Using this dataframe with quite long column headers, how can I wrap the
> text so that the columns are narrower. I was trying to use strwrap without
> success. Thanks
>
> reportDF <- structure(list(IDDate = c("3/12/2010", "3/13/2010", "3/14/2010",
> "3/15/2010"), FirstRunoftheYear = c("33 (119 ? 119)", "n (0 ? 0)", "893 (110 ?
> 146)",
> "140 (111 ? 150)"), SecondRunoftheYear = c("33 (71 ? 71)", "n (0 ? 0)",
> "337 (67 ? 74)", "140 (68 ? 84)"), ThirdRunoftheYear = c("890 (32 ? 47)",
> "n (0 ? 0)", "10,602 (32 ? 52)", "2,635 (34 ? 66)"), FourthRunoftheYear = c("0 (
> ? )",
> "n (0 ? 0)", "0 ( ? )", "0 ( ? )"), LastRunoftheYear = c("0 ( ? )", "n (0 ? 0)",
> "0 ( ? )", "0 ( ? )")), .Names = c("IDDate", "First Run of the Year", "Second
> Run of the Year",
> "Third Run of the Year", "Fourth Run of the Year", "Last Run of the Year"),
> row.names = c(NA, 4L), class = "data.frame")

I could be wrong here, but I don't think there's a way to do that as
print.data.frame is currently defined.  You might find the print.gap
argument of some use, it ultimately gets passed down to print.default
and will affect the output.

I can't think of a way to do this, hopefully someone else will have an
idea.

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