显示ggplot崩溃R.

时间:2018-03-09 14:25:04

标签: r ggplot2 rstudio

我正在尝试使用ggplot() - 包中的ggplot2创建一个情节,但是只要我执行代码,R就会崩溃,例如:

library(ggplot2)
library(data.table)

ggplot(data=dt, aes(x=year, y=value, fill=variable)) +
    geom_bar(stat="identity", width=0.85)

这种情况发生在RStudio的多个版本中以及RGUI中(与here所述的问题相反)。它发生在ggplot的任何调用上,即使使用数据帧而不是data.table作为输入。

当我将绘图保存在单独的对象中时,它不会立即崩溃。但是,一旦我尝试打印情节,一切都会崩溃。

test_plot <- ggplot(data=dt, aes(x=year, y=value, fill=variable)) +
    geom_bar(stat="identity", width=0.85)
print(test_plot)

我可以在ggplot2 - 包之外生成图表。

我已经看到ggplot2导致崩溃的报道,但这些是两年前被认为是一个RStudio错误,这似乎不是这里的情况。

有没有人见过这种行为,更重要的是,我该如何解决?

编辑:

当我不打印情节时会发生这种情况,但尝试使用ggsave()保存:

ggsave("test.png", test_plot, device = "png")

数据和会话信息

dt <- structure(list(year = c("2014", "2015", "2016", "2014", "2015", 
        "2016"), variable = c("1", "1", "1", "2", "2", "2"), value = c(82.1, 
        47.8, 60.8, 706.6, 580.2, 128.4)), .Names = c("year", "variable", 
        "value"), class = c("data.table", "data.frame"), row.names = c(NA, 
        -6L), .internal.selfref = <pointer: 0x102009f78>)

sessionInfo()
R version 3.4.3 (2017-11-30)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: OS X El Capitan 10.11.6

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] ggplot2_2.2.1       data.table_1.10.4-3

loaded via a namespace (and not attached):
[1] colorspace_1.3-2 scales_0.5.0     compiler_3.4.3   lazyeval_0.2.1   plyr_1.8.4       tools_3.4.3      pillar_1.2.1     gtable_0.2.0    
[9] tibble_1.4.2     yaml_2.1.18      Rcpp_0.12.15     grid_3.4.3       rlang_0.2.0      munsell_0.4.3   

1 个答案:

答案 0 :(得分:1)

通常,可以通过确保deps <- tools::package_dependencies("ggplot2", recursive = TRUE)$ggplot2 for (dep in deps) try(install.packages(dep)) 以及它所依赖的任何R包都是最新的来解决这些问题。您可以尝试以下内容:

services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) //TODO If I remove this default then the android client stops working (the web client will only work with this removed)
           .AddCookie(options =>
           {
               options.LoginPath = new PathString("/Development/Account/Login");
               options.AccessDeniedPath = new PathString("/Development/Account/Login");
               options.LogoutPath = new PathString("/Development/Account/Logout");
               options.ExpireTimeSpan = TimeSpan.FromDays(1);
           })
           .AddIdentityServerAuthentication(options => 
           {
               var configAuthority = container.GetInstance<IOptions<CoPilotConfig>>().Value?.IdentityAuthority;
               options.Authority = configAuthority ?? $"http://localhost:{Constants.LOOPBACK_PORT}";
               options.RequireHttpsMetadata = false;
               options.ApiName = "CoPilotApi";
           }); 

这可能最终会重新安装一些您可能已安装的软件包,但它并没有受到伤害。