[R] sparseMatrix image not working in for loop
Ivan Krylov
kry|ov@r00t @end|ng |rom gm@||@com
Mon Feb 13 08:25:32 CET 2023
On Mon, 13 Feb 2023 13:08:18 +0900
Shunran Zhang <szhang using ngs.gen-info.osaka-u.ac.jp> wrote:
> In the code, calling image(sparseMatrix) works outside
> of a for loop - the image file is written. Calling
> image(as.matrix(sparseMatrix)) also works inside a for loop thus
> eliminating file access problem. However when using
> image(sparseMatrix) inside for loop, no image file is produced, nor
> is there any error message.
image() methods for Matrix objects use lattice graphics: they
internally call levelplot(). Lattice graphics don't directly draw their
plots; instead, they return objects of class "trellis" whose
print.trellis method actually performs the drawing. (The same thing
happens with ggplot2 graphics.)
You can use plot(image(...)) or print(image(...)) to force the plot to
be rendered even when there's no auto-printing (such as when you're
inside a for loop).
--
Best regards,
Ivan
More information about the R-help
mailing list