OLGJ
OLGJ

Reputation: 442

RC class method to generate two plots with ggplot2

I have a RC-class with a plot method in r.

I have written code to run ggplot() twice, but it will only plot the latest one called. Any suggestions on why this is happening/how to fix it?

Below is an example of my structure.

testClass <- setRefClass("testClass",
                         fields   = list(
                           x = "numeric", 
                           y = "numeric"
                         ),
                         methods = list(
                           
                           initialize = function(x, y) {
                             .self$x = x
                             .self$y = y
                           },
                           
                           plot  = function() {

                             ggplot2::ggplot(...)
                             ggplot2::ggplot(...)             
                           }))

Upvotes: 0

Views: 41

Answers (0)

Related Questions