R:用于RStudio中MLR触发错误的plotLearnerPrediction ggplot对象的多重绘图

时间:2017-07-17 21:50:37

标签: r ggplot2 runtime-error rstudio mlr

文章here演示了MLR包。 plotLearnerPrediction函数按this返回ggplot对象。我尝试了为下面的ggplot2对象提供的多重绘图功能,但我的RStudio崩溃了。我可以在没有RStudio的情况下绘制事物

enter image description here

所以

如何在RStudio中并排绘制同一张图片中的多个plotLearnerPrediction对象?

library(mlr)

# Multiple plot function here failing with p1,p2,p3,... in RStudio
# but I am able to run this thing without RStudio.
# http://www.cookbook-r.com/Graphs/Multiple_graphs_on_one_page_(ggplot2)/

learners = list( makeLearner("classif.svm", kernel = "linear"), 
                 makeLearner("classif.svm", kernel = "polynomial"), 
                 makeLearner("classif.svm", kernel = "radial"), 
                 "classif.qda", 
                 "classif.randomForest", 
                 "classif.knn" )

p1<-plotLearnerPrediction(learner = learners[[1]], task = iris.task)
p2<-plotLearnerPrediction(learner = learners[[2]], task = iris.task)
p3<-plotLearnerPrediction(learner = learners[[3]], task = iris.task)
p4<-plotLearnerPrediction(learner = learners[[4]], task = iris.task)
#p5<-plotLearnerPrediction(learner = learners[[5]], task = iris.task)
#p6<-plotLearnerPrediction(learner = learners[[6]], task = iris.task)

#multiplot(p1, p2, p3, p4, p5, p6, cols=2) #failing in Rstudio
#multiplot(p1, p2, p3, p4, cols=1) #failing in Rstudio but not without it

RStudio版

> version
               _                           
platform       x86_64-apple-darwin15.6.0   
arch           x86_64                      
os             darwin15.6.0                
system         x86_64, darwin15.6.0        
status                                     
major          3                           
minor          4.1                         
year           2017                        
month          06                          
day            30                          
svn rev        72865                       
language       R                           
version.string R version 3.4.1 (2017-06-30)
nickname       Single Candle               
命令行上的

R

$ R --version
R version 3.4.1 (2017-06-30) -- "Single Candle"
Copyright (C) 2017 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin15.6.0 (64-bit)

1 个答案:

答案 0 :(得分:0)

您可以使用库global.$ = global.jQuery = require( 'jquery' ); require('jquery.validate.js'); // The library file require('form-validators.js'); // My rules and custom validation functions document.body.innerHTML = '<form id="createUser" novalidate="novalidate">' + ' <input id="create_email" name="username" required="required" value="">' + '</form>'; $('#create_email').text("AN_INVALID_EMAIL"); console.log($('#create_email').text()); // Displays the expected text: AN_INVALID_EMAIL expect($('#create_email-error').length).toEqual(1); // This fails

gridExtra