R 将绘图保存到变量,而不在屏幕上绘图

R 将绘图保存到变量,而不在屏幕上绘图,r,R,我实现了以下函数,该函数返回一个累积图列表,表示具有特定条件(data1)与失去条件(data2)之间的数据比较 library(“pryr”) myCumulativePlot调用函数时,请尝试使用invisible()包装函数ggplot2can ecdf。调用函数时,请尝试使用invisible()包装函数ggplot2can ecdf。 library("pryr") myCumulativePlot <- function (data1,data2){ f

我实现了以下函数,该函数返回一个累积图列表,表示具有特定条件(data1)与失去条件(data2)之间的数据比较

library(“pryr”)

myCumulativePlot调用函数时,请尝试使用
invisible()
包装函数
ggplot2
can ecdf。调用函数时,请尝试使用
invisible()
包装函数
ggplot2
can ecdf。
  library("pryr")   
 myCumulativePlot <- function (data1,data2){
      for(x in 1:10){
        a%<a-% {
        plot(ecdf(data1[x,]),col="red",lwd = 2,verticals = TRUE, do.points = FALSE)
        legend("topleft",c("Enriched","Depleted"),lwd=c(2.5,2.5),col=c("red","blue"))
        lines(ecdf(data2[x,]),col="blue",xaxt='n',yaxt='n', ann=FALSE,lwd = 2,verticals = TRUE, do.points = FALSE)
        }
        myData[[x]]=a
    }
    return(myData)
    }