The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.
The grobblR package allows R users the ability to intuitively create flexible, reproducible PDF reports comprised of aesthetically pleasing tables, images, plots and/or text. This is done by implementing grobs from the grid
and gridExtra
packages.
Within grobblR, the objects able to be converted to a grob are:
ggplot2
objectsNA
)grob_row()
) and grob-columns (grob_col()
) within the overall grob-layout (grob_layout()
).2 x 2
grid system on a 100mm x 100mm
(millimeters is the default unit in grobblR) page, we would simply write:library(grobblR)
grob_layout(
grob_row(grob_col(1), grob_col(2)),
grob_row(grob_col(3), grob_col(4)),
height = 100,
width = 100
%>%
) view_grob()
grob_row()
’s tell the grob_layout()
that the user wants two rows on the outermost layer, and since there are two grob_col()
’s within each of the grob_row()
’s, the result is a 2 x 2
grid.2 x 2
grid - we could have a layout where the first row has two columns and the second has one:grob_layout(
grob_row(grob_col(1), grob_col(2)),
grob_row(grob_col(3)),
height = 100,
width = 100
%>%
) view_grob()
R6
package.grob_layout(
grob_row(
border = TRUE,
grob_col(border = TRUE, 1),
grob_col(border = TRUE, 2)
),grob_row(
border = TRUE,
grob_col(border = TRUE, 3),
grob_col(
border = TRUE,
grob_row(border = TRUE, grob_col(border = TRUE, 4)),
grob_row(border = TRUE, grob_col(border = TRUE, 5))
)
),height = 100,
width = 100
%>%
) view_grob()
p
(standing for proportion) parameter within both grob_row()
and grob_col()
.p
is 1, but sizes change if p
differs from that.grob_layout(
grob_row(p = 1, border = TRUE, grob_col('1')),
grob_row(p = 2, border = TRUE, grob_col('2')),
height = 100,
width = 100
%>%
) view_grob()
p = 2
is given twice the height of the grob-row with p = 1
.grob_layout(
grob_row(height = 25, border = TRUE, grob_col('1')),
grob_row(height = 50, border = TRUE, grob_col('2')),
grob_row(height = 25, border = TRUE, grob_col('3')),
height = 100,
width = 100,
padding = 0
%>%
) view_grob()
grob_layout(
grob_row(p = 3, border = TRUE, grob_col('1')),
grob_row(height = 50, border = TRUE, grob_col('2')),
grob_row(p = 1, border = TRUE, grob_col('3')),
height = 100,
width = 100
%>%
) view_grob()
aes_list
parameter and the ga_list()
function within grob_col()
, the aesthetics of individual grobs can be adjusted to how the user intends them to appear.?grobblR::ga_list
for a full list and description for each of the possible aesthetic options.background_color
as an element within aes_list
:= matrix(1:4, nrow = 2, byrow = TRUE)
mat
grob_layout(
grob_row(
grob_col(
mat,aes_list = ga_list(background_color = "gray90")
)
),height = 100,
width = 100
%>%
) view_grob()
grob_matrix()
and alter_at()
.alter_at()
once the grob_matrix()
object is initialized.%>%
mat grob_matrix() %>%
alter_at(
~ "red",
columns = 1,
aesthetic = "text_color"
%>%
) alter_at(
~ "blue",
columns = 2,
rows = 2,
aesthetic = "background_color"
%>%
) alter_at(
~ "white",
columns = 2,
rows = 2,
aesthetic = "text_color"
%>%
) view_grob()
ggplot2
plot is stretched or squished depending on what the dimensions of the allotted space are:data(iris)
library(ggplot2)
= ggplot(
gg1 data = iris,
mapping = aes(
x = Sepal.Length,
y = Sepal.Width,
color = Species
)+
) geom_point() +
guides(color = FALSE)
#> Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
#> "none")` instead.
= ggplot(
gg2 data = iris,
mapping = aes(
x = Sepal.Length,
y = Petal.Length,
color = Species
)+
) geom_point() +
guides(color = FALSE)
#> Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
#> "none")` instead.
grob_layout(
grob_row(grob_col(gg1), grob_col(gg2)),
grob_row(grob_col(gg1))
%>%
) view_grob(height = 100, width = 100)
maintain_aspect_ratio = FALSE
must be inserted within the aes_list
list.grob_layout(
grob_row(
border = TRUE,
grob_col(
border = TRUE,
'kings_logo.png'
),grob_col(
border = TRUE,
aes_list = ga_list(
maintain_aspect_ratio = FALSE
),'https://raw.githubusercontent.com/calvinmfloyd/grobblR/master/vignettes/kings_logo.png'
)
),height = 100,
width = 100
%>%
) view_grob()
grob_image()
and add_structure()
.grob_layout(
grob_row(
border = TRUE,
grob_col(
border = TRUE,
'kings_logo.png'
),grob_col(
border = TRUE,
'https://raw.githubusercontent.com/calvinmfloyd/grobblR/master/vignettes/kings_logo.png' %>%
grob_image() %>%
add_structure("maintain_aspect_ratio", FALSE)
)
),height = 100,
width = 100
%>%
) view_grob()
= "The quick brown fox jumps over the lazy dog."
text
grob_layout(
grob_row(
border = TRUE,
grob_col(
border = TRUE,
text
)
),height = 100,
width = 100
%>%
) view_grob()
grob_text()
and add_aesthetic()
.grob_layout(
grob_row(
border = TRUE,
grob_col(
border = TRUE,
%>%
text grob_text() %>%
add_aesthetic("text_color", "blue") %>%
add_aesthetic("font_face", 3)
)
),height = 100,
width = 100
%>%
) view_grob()
= data.frame(letter = letters[1:5], col1 = 1:5, col2 = 5:1)
df
grob_layout(
grob_row(
border = TRUE,
grob_col(df),
grob_col(
grob_row(grob_col(df)),
grob_row(grob_col(p = 1/3, NA))
),grob_col(
grob_row(grob_col(p = 1/3, NA)),
grob_row(grob_col(df))
)
),height = 100,
width = 100
%>%
) view_grob()
height
and width
parameters within grob_layout()
are 280
millimeters and 216
millimeters, as these are the values needed to properly fit the grob-layout onto a piece of standard computer paper, portrait orientation.grob_to_pdf()
, with a file title and a meta data title:= grob_layout(
first_page_grob_layout grob_row(
border = TRUE,
grob_col(df),
grob_col(
grob_row(grob_col(df)),
grob_row(grob_col(p = 1/3, NA))
),grob_col(
grob_row(grob_col(p = 1/3, NA)),
grob_row(grob_col(df))
)
),height = 100,
width = 100
)
= grob_layout(
second_page_grob_layout grob_row(
border = TRUE,
grob_col(
border = TRUE,
text
)
),height = 100,
width = 100
)
# grob_to_pdf(
# first_page_grob_layout,
# second_page_grob_layout,
# file_name = file.path(tempdir(), "test.pdf"),
# meta_data_title = 'Test PDF'
# )
# OR
grob_to_pdf(
list(first_page_grob_layout, second_page_grob_layout),
file_name = file.path(tempdir(), "test.pdf"),
meta_data_title = "Test PDF"
)
The grobblR package provides R users a tool to quickly create dynamic and aesthetically pleasing PDF reports. In the future we hope to enhance and add even more features, but, even as it currently stands, we believe grobblR is a valuable utility in daily data visualization and data reporting tasks.
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.