addImage | R Documentation |
Insert either an existing image or the current plot into a worksheet.
addImage(
onesheet,
image,
line,
col,
wide = 7,
high = 4,
unit = "in",
spec.dpi = 300,
wb = NULL
)
onesheet |
A sheet object from openXlsx package |
image |
The filename of a previously saved image (format supported: jpeg, bmp, png) or the name of the image in the current R environment |
line |
The line where to paste the image |
col |
The column where to paste the image |
wide |
Size of the image (in unit) |
high |
Size of the image (in unit) |
unit |
For wide and high, default is "in" (Inch) "cm" or "px" |
spec.dpi |
300 by default |
wb |
An optional wb if not already opened |
Nothing
Jenny Howard, Marine Maurel
openxlsx::insertImage()
, openxlsx::insertPlot()
## Not run:
addImage(onesheet = cells,
image = graphname,
line = 2,
col = 2,
wb = template)
## End(Not run)
# Usage 1: Insert existing image saved as a PNG file
xls_file <- externalFile("excelfile.xlsx")
openXlsx(xls_file)
cells <- openSheet("T2")
image_file <- externalFile("image_xlsx.png")
addImage(onesheet = cells, image = image_file, line = 20, col = 2)
# Usage 2: Insert current plot
## Not run:
image_gg <- ggplot(Orange,
aes(x = age, y = circumference, colour = as.factor(Tree))) +
geom_point() +
geom_line() +
labs(colour = "Tree") +
theme_minimal()
addImage(onesheet = cells, image = image_gg, line = 20, col = 2)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.