如何读取 SVG 文件并使用 r 将它们合二为一

how to read SVG files and combine them all in one using r

我有 7 个不同的图形保存为 SVG 格式。 我想使用 R 将它们合二为一。 请告诉我该怎么做? 我看到下面的 link 但它不在 r Merging multiple SVG files into one

最好的, 阿玛尔

您可以读取 svg 文件,将它们转换为 ggplot2 对象并使用 patchwork 运算符,例如| 垂直堆叠:

library(patchwork)
library(magick)

(
  image_read("circle.svg") |> image_ggplot() |
  image_read("rect.svg") |> image_ggplot()
)