twitter / AnomalyDetection

Anomaly Detection with R
GNU General Public License v3.0
3.55k stars 779 forks source link

Consider changing 'plot.new()' to 'NULL' in the output when 'plot = FALSE' #73

Open FrankPortman opened 8 years ago

FrankPortman commented 8 years ago

Line 287 - 291 of vec_anom_detection.R (and similarly in ts) is:

 if(plot){
    return (list(anoms = anoms, plot = xgraph))
  } else {
    return (list(anoms = anoms, plot = plot.new()))
  }

Consider changing the plot = plot.new() to plot = NULL or removing it altogether. When using in a non interactive environment (such as a Shiny app), this can run into issues with plot devices since 'plot.new()' interactively builds a plot.

The current workaround is to set plot = TRUE in the function call and then just never use the plot in your code but it would be cleaner to change this in the code directly.

FrankPortman commented 8 years ago

I see there's an active pull request out for this since October 2015 with multiple people supporting it.