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.

0

1 Answer 1

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.

3
  • 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.
    – XiaokangZH
    Feb 23, 2017 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, 2017 at 14:09
  • Learnt something new. Thx!
    – XiaokangZH
    Feb 23, 2017 at 19:55

Not the answer you're looking for? Browse other questions tagged or ask your own question.