r - R 不执行命令行
问题描述
我正在尝试通过 R 代码执行命令行(帖子末尾的整个脚本)
system('"C:\\Program Files\\ImageMagick-7.0.8-Q16\\convert.exe" -delay 20 -loop 0 *.png julia.gif')
当然,我下载并安装了ImageMagick并验证C:\Program Files\ImageMagick-7.0.8-Q16
存在于我的机器上
期望的结果是从输出(35 个 .png 文件,GitHub 上的副本)创建下面的动画。
语法看起来正确,我忽略了什么?
R 代码(灵感来自Fronkonstin 博客)
library(ggplot2)
library(dplyr)
library(RColorBrewer)
setwd("C:/JuliaSet")
dir.create("output")
setwd("output")
f = function(z,c) exp(z^3)+c
# Grid of complex
z0 <- outer(seq(-2, 2, length.out = 1200),1i*seq(-2, 2, length.out = 1200),'+') %>% c()
opt <- theme(legend.position="none",
panel.background = element_rect(fill="white"),
plot.margin=grid::unit(c(1,1,0,0), "mm"),
panel.grid=element_blank(),
axis.ticks=element_blank(),
axis.title=element_blank(),
axis.text=element_blank())
for (i in 1:35)
{
z=z0
# i iterations of f(z)
for (k in 1:i) {
z <- f(z, c=-0.621)
df=data.frame(x=Re(z0),
y=Im(z0),
z=as.vector(exp(-Mod(z)))) %>% na.omit()
}
p=ggplot(df, aes(x=x, y=y, color=z)) +
geom_tile() +
scale_x_continuous(expand=c(0,0))+
scale_y_continuous(expand=c(0,0))+
scale_colour_gradientn(colours=brewer.pal(8, "Paired")) + opt
ggsave(plot=p, file=paste0("plot", stringr::str_pad(i, 4, pad = "0"),".png"), width = 1.2, height = 1.2)
}
# Place the exact path where ImageMagick is installed
system('"C:\\Program Files\\ImageMagick-7.0.8-Q16\\convert.exe" -delay 20 -loop 0 *.png julia.gif')
# cleaning up
#file.remove(list.files(pattern=".png"))
解决方案
推荐阅读
- python - 如何处理 div 类型的下拉菜单,而不是在 selenium/python 中选择
- pandas - 数据框python从年,月,日转换为工作日
- java - 在 MapStruct 中转换为相同的子对象
- reactjs - Reactstrap 输入验证错误。需要帮助
- javascript - 没有从reactjs中的输入字段编辑值
- arrays - Xcode 如何声明我的单元格以显示我的 UITableViewCell?
- ibm-cloud - 如何让 Watson Assistant 将 3 小时识别为 3 小时后?
- c# - 突出显示 HTML 表格中的重复单元格
- recursion - 了解关于 Agda 中 FSA 和常规语言的简单证明的递归调用失败
- asp.net-mvc - 问题是绑定模型是一个复杂的模型