[rkward-devel] RV: Problems with ggplot2

SANCHEZ ALBERCA, ALFREDO asalber at ceu.es
Tue Jun 25 13:42:27 UTC 2013


The plugin is in Spanish, but I'm translating it to English now, and I will share it in a few weeks.
The code for generating the graphic it's a bit complicated, and that no helps to understand the problem.
So I've tried to do a simple example with your code, just putting it inside the doPrintout(full) function:
function doPrintout (full) {
        echo ('print(qplot(mpg, wt, data=mtcars))\n');
}

and I get the graphic in a new window, but no in the output window rk_out.html
Thanks!
________________________________________
Hi!

On Monday 17 June 2013 15:07:32 SANCHEZ ALBERCA, ALFREDO wrote:
> I have a RKWard plugin that plot some graphics and I wan to update it to use
> ggplot2. When I use the plot function I get the graphics without problems,
> but when I use the qplot function of package ggplot2, I get nothing.
> However, it works when I use the command line.
> Has anybody tried ggplot2 with RKWard?

As Meik has pointed out, some example lines of (generated) code would be
useful. But as a first guess, the gotcha is auto-printing:

ggplot2 functions, in contrast to "regular" plotting functions, do not
actually "have the side-effect" of creating a plot, but rather they create an
object, that - when printed - creates a plot. When running code on the top-
level, line by line, values get auto-printed. But once you leave the top-level
(as does all plugin code), the difference becomes visible. Consider these
examples:

{ qplot(mpg, wt, data=mtcars); 1 }
{ x <- qplot(mpg, wt, data=mtcars); 1; x }
{ print(qplot(mpg, wt, data=mtcars)); 1 }

The third example should point to the correct solution: Call print(),
explicitly, to make the plot show up.

Regards
Thomas




More information about the Rkward-devel mailing list