r - R卡在anim_save中的渲染
问题描述
我尝试在下面运行此代码。我遇到的问题是,如果我不设置宽度和高度,它会保存,如果我设置宽度和高度,它就会卡在运行中而没有保存(我试着让它运行一天)。我还在多台机器上尝试了代码。非常感谢您的帮助
## Data generation (This works, but is included to reproduce the exact data)
set.seed(2711)
library('MASS')
library(tidyverse)
library(magrittr)
library(gganimate)
group_loop_df <-
lapply(seq(100, 1000, 100), function(sample_size){
test1 <- data.frame(V1 = truncnorm::rtruncnorm(sample_size, 1, 10, 5, 2))
summary_test <- Rmisc::summarySE(test1, "V1")
test1$ci_V1 <- summary_test$ci
test1$sd_V1 <- summary_test$sd
test1$mean_V1 <- summary_test$V1
hist_data <- ggplot_build(ggplot(test1) +
aes(x = V1) +
geom_histogram() +
theme_classic())$data[[1]]
test1$ceiling_var <- max(hist_data$count)
test1$sample_size <- sample_size
test1$group <- "Group 1"
test2 <- data.frame(V1 = truncnorm::rtruncnorm(sample_size, 1, 10, 4, 2))
summary_test <- Rmisc::summarySE(test2, "V1")
test2$ci_V1 <- summary_test$ci
test2$sd_V1 <- summary_test$sd
test2$mean_V1 <- summary_test$V1
hist_data <- ggplot_build(ggplot(test2) +
aes(x = V1) +
geom_histogram() +
theme_classic())$data[[1]]
test2$ceiling_var <- max(hist_data$count)
test2$sample_size <- sample_size
test2$group <- "Group 2"
overall <- rbind(test1, test2)
overall$p <- t.test(V1 ~ group, overall)$p.value
overall
}) %>%
do.call(rbind, .)
full_hist_overlap <- ggplot(group_loop_df) +
geom_histogram(aes((y=..count../sum(..count..)) * 100, x = V1, fill = group) ) +
geom_vline(aes(xintercept = mean_V1, color = group), size = 2) +
geom_vline(aes(xintercept = mean_V1 - ci_V1, color = group), linetype = "dashed", size = 2) +
geom_vline(aes(xintercept = mean_V1 + ci_V1, color = group), linetype = "dashed", size = 2) +
theme_classic() +
labs(y = "Percent of Values", x = NULL) +
transition_states(sample_size,
transition_length = 5,
state_length = 10) +
ggtitle('Now showing {closest_state} samples') +
ease_aes('cubic-in-out')
### This is where the error occurs.
### This works
anim_save("hist_overlap.gif")
### This does not
anim_save("hist_overlap.gif", units = "cm",
width = 25.4, height = 14.288, res = 300)
解决方案
推荐阅读
- azure - 如何使用绑定域(天蓝色之外)将 SSL 证书(FPX)设置为 Microsoft Azure
- java - 用于 JUnit 测试功能的 CodeLens 不会出现在 VSCode 中
- c# - IO 设备(如 HDD 示例)是否可以在没有 CPU 的情况下工作?
- android - 在 Android 10 上从 contentProvider 加载所有图像
- c - 需要帮助将 char* 扫描到具有结构的函数中
- html - 显示带有选中复选框的选项无法统一工作
- python - Python中基于字符串/整数序列的聚类和距离/相异矩阵
- android - 为什么 DJI Mobile SDK 需要 Android 物理设备,而不能与 Android 虚拟机配合使用?
- haskell - 将 Haskell 函数“分解”为具有各种中间类型的两个函数时如何避免重复?
- xquery - Xquery 无法将 XML HTTP 内容作为 XML 文档访问