can i convert a base plot in r to a ggplot object? -


i'm new r , love ggplot - that's use plotting, don't know archaic syntax needed base plots in r (and i'd rather not have learn it). i'm running proc::roc , plot output in ggplot (so can fine tune how looks). can plot follows:

size <- 100 response <- sample(c(0,1), replace=true, size=size) predictor <- rnorm(100) rocobject <- proc::roc(response, predictor,smooth=t) plot(rocobject) 

to use ggplot instead, can create data frame output , use ggplot (this not question). want know if can somehow 'convert' plot made in code above ggplot automatically can want in ggplot? i've searched on , can't seem find answer 'basic' question. thanks!!

no, think unfortunately not possible.

even though not answer real question, building ggplot not difficult.

your original plot:

plot(rocobject) 

enter image description here

in ggplot:

library(ggplot2) df<-data.frame(y=unlist(rocobject[1]), x=unlist(rocobject[2])) ggplot(df, aes(x, y)) + geom_line() + scale_x_reverse() + geom_abline(intercept=1, slope=1, linetype="dashed") + xlab("specificity") + ylab("sensitivity") 

enter image description here


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

delphi - Take screenshot in webcam using VFrames in Console Application -

swift - Cannot convert return expression type to return type with closure? -