JuliaGizmos / Escher.jl

Composable Web UIs in Julia
https://juliagizmos.github.io/Escher.jl
Other
335 stars 63 forks source link

Output in web too plain #159

Closed davin777 closed 7 years ago

davin777 commented 8 years ago

http://stackoverflow.com/questions/37460509/output-in-julia-escher-jl-in-web-very-plain

Help me i just want the output from this screenshot from 2016-05-26 18-54-42 screenshot from 2016-05-26 18-54-49

to this the output like in the R console

screenshot from 2016-05-26 19-00-20 screenshot from 2016-05-26 19-00-51

the code (yes i know its weird, my professor making it complicated i have to call from RCall)

using RCall
using ImageView, Images 

R"library(NLP)"
R"library(RColorBrewer)"
R"library(tm)"
R"library(SnowballC)"
R"library(e1071)"
R"library(gplots)"
R"library(ROCR)"
R"library(gmodels)"
R"library(caret)"
R"library(xtable)"
R"sms_raw <- read.csv('/home/r/sms_spam.csv', stringsAsFactors = FALSE)"
R"str(sms_raw)"
R"summary(sms_raw)"
R"sms_raw$type <- factor(sms_raw$type)"

R"sms_results <- read.csv('/home/r/sms_results.csv')"
R"confusionMatrix(sms_results$predict_type, sms_results$actual_type, positive = 'spam')"
R"pred <- prediction(predictions = sms_results$prob_spam, labels = sms_results$actual_type)"
R"perf <- performance(pred, measure = 'tpr', x.measure = 'fpr')"

    R"plot(perf, main = 'ROC curve for SMS spam filter', col = 'blue', lwd = 2)"

using Compose
using Colors

# define the `sierpinski` triangle function
function sierpinski(n)
    if n == 0
        compose(context(), polygon([(1,1), (0,1), (1/2, 0)]))
    else
        t = sierpinski(n - 1)
        compose(context(),
                (context(1/4,   0, 1/2, 1/2), t),
                (context(  0, 1/2, 1/2, 1/2), t),
                (context(1/2, 1/2, 1/2, 1/2), t))
    end
end

main(window) = compose(sierpinski(6))

function main(window)
    # load assets
    push!(window.assets, "layout2")
    push!(window.assets, "tex")

    # create the tabs
    tabbar = tabs([
         hbox("Sierpinski"),
         hbox("R"),
         hbox("R"),
     hbox("R"),
     hbox("R"),
     hbox("R"),
     hbox("R"), 

    ])

    # create the pages
    tabcontent = pages([
        sierpinski(5),
        R"str(sms_raw)",
    R"confusionMatrix(sms_results$predict_type, sms_results$actual_type, positive = 'spam')",
    R"png('rplot.png')",
    image("/root/.julia/v0.4/Escher/examples/myplot.png"),
    tex("Help  Me"),
    title(3, "T "),

    ])

    # connect the tabs to pages
    # returns a pair of "connected" tab set and pages
    t, p = wire(tabbar, tabcontent, :tab_channel, :selected)

    # stack them on top of each other
    vbox(t, p)
end

Help Anyone....

shashi commented 8 years ago

Have you tried putting the output in a code container? e.g. code(R"str(sms_raw)"). also try Elem(:pre, R"str(sms_raw)") and see which one works better for you.

davin777 commented 8 years ago

still cant.... code still plain and elem with error

MethodError: `start` has no method matching start(::RCall.RObject{RCall.NilSxp})
 in anonymous at /root/.julia/v0.4/Escher/src/cli/serve.jl:170
 in anonymous at /root/.julia/v0.4/Mux/src/Mux.jl:15
shashi commented 8 years ago

Well you need to figure out a way to get the string representation of the RCall object. You can try something like string(R"str(sms_raw)") and see if it works. What does print(R"str(sms_raw)") look like in Julia REPL?

davin777 commented 8 years ago

its false...., and string just got more weirder... but thank you for good response...

shashi commented 8 years ago

there must be a function you can call in R to get back string that is formatted like that. You need it to do this. Or else you can walk the object and create your own table using Escher boxes.

davin777 commented 8 years ago

string above is in REPL. How to Escher boxes ? any tutorial lead to this ? thank you...

shashi commented 8 years ago

If you can construct a dataframe for example, you can display the dataframe in Escher using the table function. Otherwise, you could also create your own table just by using hboxes and vboxes...

davin777 commented 8 years ago

So, R could Export the data to image... how to show image in Escher.jl ? image("/root/.julia/v0.4/Escher/examples/myplot.png") code above doesnt show anything...

randyzwitch commented 7 years ago

Closing, as this is a tutorial as opposed to bug/feature request. If you're still having issues/questions, please post at julia-users, and if there are concrete feature requests, feel free to open a new issue here.

https://groups.google.com/forum/#!forum/julia-users