我有兴趣使用以下命令从我的计算机读取 png 文件并从中生成多个文件。
plot(0:2, 0:2, type = "n", xaxt = "n", yaxt = "n", xlab = "", ylab = "")
rasterImage(readPNG(source="ArgentinaTotal.png"), 0, 1, 1, 2)
rasterImage(readPNG(source="BrazilTotal.png"), 1, 1, 2, 2)
rasterImage(readPNG(source="ChileTotal.png"), 0, 0, 1, 1)
rasterImage(readPNG(source="ColombiaTotal.png"), 1, 0, 2, 1)
Run Code Online (Sandbox Code Playgroud)
这些命令适用于 2X2 设置,但如果我想要 2 列和 4 行的倍数,我该怎么办?我使用了以下代码:
plot(0:2, 0:4, type = "n", xaxt = "n", yaxt = "n", xlab = "", ylab = "")
Run Code Online (Sandbox Code Playgroud)
但我收到一条错误消息:
Error in xy.coords(x, y, xlabel, ylabel, log) :
'x' and 'y' lengths differ
Run Code Online (Sandbox Code Playgroud) r ×1