Home>

I want to draw a graph using ggplot2 in Julia, but I get an error and I can't.
Can anyone help me because I don't know the solution?

The data is as follows.

head (df)
Out [55]:
tpr fpr line
Any Any String
1 0.0 0.000712758 honban
2 0.0 0.00142552 honban
3 0.0 0.00213828 honban
4 0.0 0.00285103 honban
5 0.0 0.00356379 honban
6 0.0 0.00427655 honban

If i execute the following,

using RCall
@rlibrary ggplot2
@rlibrary ggsci
@rlibrary reshape2
ggplot (df, aes (x =: fpr, y =: tpr)) + geom_line ()


An error like this will appear.

REvalError: order (c (1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, error:
   Type 'list' (in 'listgreater') is not implemented
Stacktrace:
 [1] macro expansion at ./logging.jl:307 [inlined]
 [2] # handle_eval_stderr # 41 (:: Bool, :: Function) at /Users/shotaro/.julia/packages/RCall/Q4n8R/src/io.jl:110
 [3] #handle_eval_stderr at ./none:0 [inlined]
 [4] rprint (:: IOContext {Base.GenericIOBuffer {Array {UInt8,1}}}, :: Ptr {VecSxp}) at /Users/shotaro/.julia/packages/RCall/Q4n8R/src/io.jl: 33
 [5] rprint at /Users/shotaro/.julia/packages/RCall/Q4n8R/src/io.jl:43 [inlined]
 [6] show at /Users/shotaro/.julia/packages/RCall/Q4n8R/src/io.jl:49 [inlined]
 [7] show at ./sysimg.jl:194 [inlined]
 [8] limitstringmime (:: MIME {Symbol ("text/plain")}, :: RObject {VecSxp}) at /Users/shotaro/.julia/packages/IJulia/0cLgR/src/inline.jl:36
 [9] display_mimestring (:: MIME {Symbol ("text/plain")}, :: RObject {VecSxp}) at /Users/shotaro/.julia/packages/IJulia/0cLgR/src/execute_request.jl:73
 [10] display_dict (:: RObject {VecSxp}) at /Users/shotaro/.julia/packages/IJulia/0cLgR/src/execute_request.jl:101
 [11] # invokelatest # 1 at ./essentials.jl:697 [inlined]
 [12] invokelatest at ./essentials.jl:696 [inlined]
 [13] execute_request (:: ZMQ.Socket, :: IJulia.Msg) at /Users/shotaro/.julia/packages/IJulia/0cLgR/src/execute_request.jl:256
 [14] # invokelatest # 1 at ./essentials.jl:697 [inlined]
 [15] invokelatest at ./essentials.jl:696 [inlined]
 [16] eventloop (:: ZMQ.Socket) at /Users/shotaro/.julia/packages/IJulia/0cLgR/src/eventloop.jl:8
 [17] (:: getfield (IJulia, Symbol ("## 12 # 15"))) () at ./task.jl:259


By the way, it was useless as follows.

R "" "
g<-ggplot ($roc, aes (x = FalsePositiveRate, y = TruePositiveRate))
g<-g + geom_line ()
g<-g + scale_color_nejm ()
plot (g)
"" "
REvalError: order (c (1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, error:
   Type 'list' (in 'listgreater') is not implemented
Stacktrace:
 [1] macro expansion at ./logging.jl:307 [inlined]
 [2] # handle_eval_stderr # 41 (:: Bool, :: Function) at /Users/shotaro/.julia/packages/RCall/Q4n8R/src/io.jl:110
 [3] #handle_eval_stderr at ./none:0 [inlined]
 [4] reval_p (:: Ptr {LangSxp}, :: Ptr {EnvSxp}) at /Users/shotaro/.julia/packages/RCall/Q4n8R/src/eval.jl:99
 [5] reval_p (:: Ptr {RCall.ExprSxp}, :: Ptr {EnvSxp}) at /Users/shotaro/.julia/packages/RCall/Q4n8R/src/eval.jl:115
 [6] reval (:: String, :: RObject {EnvSxp}) at /Users/shotaro/.julia/packages/RCall/Q4n8R/src/eval.jl:132
 [7] top-level scope at /Users/shotaro/.julia/packages/RCall/Q4n8R/src/macros.jl:67
 [8] top-level scope at In [58]: 1

I can do this ...

R "" "
d = data.frame (x = 1: 20, y = cos (1:20), z = c (rep ("red", 10), rep ("blue", 10)))
g<-ggplot (d, aes (x = x, y = y, color = z)) + geom_line ()
"" "
  • Answer # 1

    I did it after I first specified the type.

    TPR = Float64 []
    FPR = Float64 []
    ....
    using RCall
    @rlibrary ggplot2
    @rlibrary ggsci
    @rlibrary reshape2
    ggplot (roc, aes (x =: fpr, y =: tpr)) + geom_line ()