Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ggplot2 fails with RProvider #161

Closed
evelinag opened this issue Nov 14, 2015 · 2 comments · Fixed by #162
Closed

ggplot2 fails with RProvider #161

evelinag opened this issue Nov 14, 2015 · 2 comments · Fixed by #162

Comments

@evelinag
Copy link
Contributor

I was using ggplot2 from RProvider, but it stopped working from RProvider version 1.1.12. Ggplot normally composes plots by adding layers and the resulting plot needs to be evaluated as a whole. Currently, each layer is evaluated immediately which leads to no layers in plot errors.

Code to reproduce the error:

open RProvider
open RProvider.graphics
open RProvider.ggplot2
open RProvider.datasets

let (++) (plot1:RDotNet.SymbolicExpression) (plot2:RDotNet.SymbolicExpression) =
    R.``+``(plot1, plot2)

fsi.AddPrinter(fun (synexpr:RDotNet.SymbolicExpression) ->
    synexpr.Print())

let mtc = R.mtcars
R.assign("mtc", mtc)
R.eval(R.parse(text = "library(ggplot2)"))

// fails because the first call to ggplot is evaluated individually
R.eval(R.parse(text = "ggplot(mtc, aes(x=disp, y=drat))")) ++ R.geom__point()

The code worked in RProvider 1.1.8.

@tpetricek
Copy link
Member

I had a look at this and it seems to be caused by the fact that R.NET now automatically prints the results of expressions evaluated (this change sets AutoPrint to true). AFAIK this has no effect on R provider, because we are not capturing the automatic print output.

The reason why this breaks the above code is that R tries to show the incomplete chart created by the first part of the expression (before the ++). I think we can safely set AutoPrint = false in R provider because our F# Interactive load script prints things explicitly.

tpetricek added a commit to tpetricek/FSharp.RProvider that referenced this issue Nov 14, 2015
@evelinag
Copy link
Contributor Author

It works now, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants