RCall.jl icon indicating copy to clipboard operation
RCall.jl copied to clipboard

rendering ggplot in html output

Open vjd opened this issue 5 years ago • 5 comments

I am using RCall in .jmd file where I used the mtcars dataset to make a simple ggplot.

using RCall
mtcars = rcopy(R"mtcars")
R"""
(p <- ggplot(mtcars, aes(drat, wt)) + geom_point())
"""

What do I need to do to get this rendered in the html file that is weaved? This the output I get

image

Obviously, just printing p in the julia chunk throws an error. Am I missing something?

vjd avatar Jan 06 '20 06:01 vjd

Possible duplicate of #340

palday avatar Mar 04 '20 11:03 palday

What should happen if you call

R"""
ggplot(mtcars, aes(drat, wt)) + geom_point()
"""

in a jmd file? In a Jupyter notebook, the resulting figure is shown. I cannot get this to work in a Julia markdown file, though.

awellis avatar Apr 04 '20 20:04 awellis

in the interactive mode in a jmd file, it will produce an external window where the ggplot2 is rendered. But when you weave the document, it does not render.

vjd avatar Apr 04 '20 20:04 vjd

It certainly renders, but is there no way to get the output included in the weaved markdown file?

awellis avatar Apr 04 '20 20:04 awellis

doing this has the same result:

using RCall, DataFrames

d = DataFrame(v = [3,4,5], w = [5,6,7], x = [1,2,3], y = [4,5,6], z = [1,1,2])
ggplot(d, aes(x=:x,y=:y)) + geom_line()

awellis avatar Apr 04 '20 20:04 awellis