From 9902ab9f182209d5ab76bc567fa6e4272ecfad78 Mon Sep 17 00:00:00 2001 From: lch34677 Date: Wed, 1 Jan 2020 13:58:40 -0500 Subject: [PATCH 1/5] Refactoring with require. --- inst/julia/display/RmdJulia.jl | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/inst/julia/display/RmdJulia.jl b/inst/julia/display/RmdJulia.jl index c1c666aa..2b2fef66 100644 --- a/inst/julia/display/RmdJulia.jl +++ b/inst/julia/display/RmdJulia.jl @@ -20,14 +20,39 @@ function text_display(display::RmdDisplay, x) text_display_in_R(s) end -function display(display::RmdDisplay, x) - try - if isa(x, Main.Plots.Plot) +if julia07 + using Requires +else + macro require_str() end +end + +@require Plots="91a5bcdd-55d7-5caf-9e0b-520d859cae80" @eval begin + + function display(display::RmdDisplay, x::Plots.Plot) + try plot_display(display, x) return + catch e; end - catch e; + try + text_display(display, x) + return + catch e; + end + throw(MethodError) end + + function plot_display(display::RmdDisplay, x::Plots.Plot) + path = rcopy(begin_plot_in_R()) + mkpath(dirname(path)) + Plots.savefig(x, path) + finish_plot_in_R() + end + +end + + +function display(display::RmdDisplay, x) try text_display(display, x) return From 105221366978c843cc1f2a8fa6629fd4622f8f86 Mon Sep 17 00:00:00 2001 From: lch34677 Date: Wed, 1 Jan 2020 14:07:31 -0500 Subject: [PATCH 2/5] Some correction. --- inst/julia/display/RmdJulia.jl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/inst/julia/display/RmdJulia.jl b/inst/julia/display/RmdJulia.jl index 2b2fef66..8ce22977 100644 --- a/inst/julia/display/RmdJulia.jl +++ b/inst/julia/display/RmdJulia.jl @@ -53,6 +53,13 @@ end function display(display::RmdDisplay, x) + try + if isa(x, Main.Plots.Plot) + plot_display(display, x) + return + end + catch e; + end try text_display(display, x) return From 410059e75c0150c673eab16c064dc8f19799f9b1 Mon Sep 17 00:00:00 2001 From: lch34677 Date: Wed, 1 Jan 2020 15:15:30 -0500 Subject: [PATCH 3/5] Package installation for Requires. --- inst/julia/install_dependency.jl | 5 +++++ inst/julia/rebuildRCall.jl | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/inst/julia/install_dependency.jl b/inst/julia/install_dependency.jl index d35534d6..397d3896 100644 --- a/inst/julia/install_dependency.jl +++ b/inst/julia/install_dependency.jl @@ -32,3 +32,8 @@ using Suppressor if installed("RCall") == nothing Pkg.add("RCall") end; + +if julia07 && installed("Requires") == nothing + Pkg.add("Requires") + using Requires +end; diff --git a/inst/julia/rebuildRCall.jl b/inst/julia/rebuildRCall.jl index 3468148a..fb83ad53 100644 --- a/inst/julia/rebuildRCall.jl +++ b/inst/julia/rebuildRCall.jl @@ -31,6 +31,11 @@ end; using Suppressor +if julia07 && installed("Requires") == nothing + Pkg.add("Requires") + using Requires +end; + if installed("RCall") == nothing Pkg.add("RCall") end; From 11cf84c3689f8ac449691d046e5e29c2ca3f0214 Mon Sep 17 00:00:00 2001 From: lch34677 Date: Wed, 1 Jan 2020 15:53:28 -0500 Subject: [PATCH 4/5] Bump version. [skip ci] --- DESCRIPTION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index aa6f5944..1e19149f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: JuliaCall Type: Package Title: Seamless Integration Between R and 'Julia' -Version: 0.17.1 -Date: 2019-11-26 +Version: 0.17.1.9999 +Date: 2020-01-01 Authors@R: c( person("Changcheng", "Li", , "cxl508@psu.edu", c("aut", "cre")), person("Randy", "Lai", role = "ctb"), From f1875039e5aa73cbb239cf42e459bf438e46f165 Mon Sep 17 00:00:00 2001 From: lch34677 Date: Wed, 1 Jan 2020 18:23:21 -0500 Subject: [PATCH 5/5] Add the dependency of mime. --- DESCRIPTION | 5 +++-- NAMESPACE | 1 + R/JuliaCall.R | 1 + man/grapes-greater-than-J-grapes.Rd | 4 ++-- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 1e19149f..15a56c99 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -25,8 +25,9 @@ Encoding: UTF-8 LazyData: true Imports: utils, Rcpp (>= 0.12.7), - knitr (>= 1.18) -RoxygenNote: 7.0.0 + knitr (>= 1.18), + mime (>= 0.8) +RoxygenNote: 7.0.2 LinkingTo: Rcpp NeedsCompilation: yes ByteCompile: yes diff --git a/NAMESPACE b/NAMESPACE index 4ff55da0..7003be55 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -78,5 +78,6 @@ export(julia_source) export(julia_update_package) export(plotsViewer) import(Rcpp) +import(mime) importFrom(knitr,knit_print) useDynLib(JuliaCall) diff --git a/R/JuliaCall.R b/R/JuliaCall.R index abcf96ef..d112a107 100644 --- a/R/JuliaCall.R +++ b/R/JuliaCall.R @@ -54,5 +54,6 @@ #' @docType package #' @useDynLib JuliaCall #' @import Rcpp +#' @import mime #' @name JuliaCall NULL diff --git a/man/grapes-greater-than-J-grapes.Rd b/man/grapes-greater-than-J-grapes.Rd index 67db5e68..312373c9 100644 --- a/man/grapes-greater-than-J-grapes.Rd +++ b/man/grapes-greater-than-J-grapes.Rd @@ -16,8 +16,8 @@ The experimental language piper for julia language. } \examples{ \donttest{ ## julia_setup is quite time consuming - 2 %>J% sqrt - 3 %>J% log(2) + 2 \%>J\% sqrt + 3 \%>J\% log(2) } }