1

I am using the R package "GeoDE". When I use the function "chdirAnalysis", a figure will be plotted automatically, since there is a command "plot" in the source code of "chdirAnalysis". But I don't want that. How can I stop this?

A similar problem is to hide the in-function printed messages, and I've found the solution which is to use invisible

capture.output(value <- function_name(input))

That can help hide the output from "function_name", but this solution doesn't work on the plot.

siddhartha jain
  • 1,006
  • 10
  • 16
Xiaokang
  • 331
  • 1
  • 11

1 Answers1

2

Options:

  1. Ask the maintainer to add a plot=FALSE option to the function (and maybe a verbose=FALSE option to stop the text outputs).

  2. Edit the source for chdirAnalysis and remove the function call that does the plotting, or hide it behind a new plot=FALSE options. I think this is chdirplots, which is called but doesn't do anything with its return value. If you are doing this outside the GeoDE package source then you'll need to add the GeoDE::: prefix to any unexported GeoDE functions called by chdirAnalysis (such as chdirSig).

  3. Make it plot to some dummy or throwaway graphics device file, as described in other questions and answers.

Spacedman
  • 92,590
  • 12
  • 140
  • 224
  • Thank you @Spacedman. I'll do that as "1". For 2, that's very helpful. Since I tried to paste the definition of `chdirAnalysis` in my code, and modified it by removing the plot part, but as it will call another function in the package `chdirSig`, I had to paste that function's definition to my code. But `GeoDE:::` solves this problem perfectly! For 3, sorry, but I don't understand. – Xiaokang Feb 23 '17 at 12:50
  • (3) Is doing something like `pdf(file="/dev/null")` which opens a graphics device that sends its output to a PDF file which (on Linux/Unix) just goes nowhere. You could even send it to a real file, like `t = tempfile();pdf(file=t); doplotstuff(...); dev.off();file.remove(t)` and that won't do it on screen. – Spacedman Feb 23 '17 at 14:09
  • Learnt something new. Thx! – Xiaokang Feb 23 '17 at 19:55