Oda Ned
Oda Ned

Reputation: 47

Convert rdplot in the rdrobust library to ggplot

Is there any way to convert an rdplot from the rdrobust library in R to a ggplot object? There are many specifications that do not work in the rdplot format (layout and grobs), so it would be nice to be able to work with the figure in another format.

Thanks!

Some random code for rdplot:

library(rdrobust)

theta <- 1:100
diff <- -50:49

rdplot(theta, diff, p=1, binselect="qs", nbins=c(15, 5))

Upvotes: 1

Views: 738

Answers (1)

Oda Ned
Oda Ned

Reputation: 47

The rdplot can be converted into a ggplot by accessing it via $rdplot:

p1 <- rdplot(theta, diff, p=1, binselect="qs", nbins=c(15, 5))

p1 <- p1$rdplot

> class(p1)
[1] "gg"     "ggplot"

Upvotes: 1

Related Questions