开发者

How to get started with creating an R application that is based on / uses JGR?

can anyone point me to a good start for developing a JGR dependable R application? Roughly speaking I want to do something that enhances the JGR menu by some options just like Deducer (btw now available with ggplot2!!) does (of course I want to do it in a much much simpler way). Basically the application is a GUI for rendering periodical reports that use Sweave .Rnw as some "templating language", but have some frequently changing text.

So ...

1) Is it reasonable to connect it to R / JGR ? or should I 开发者_StackOverflow社区just create some stand-alone Java program or Python script that does the job... ?

2) Which part should be written in Java and which in R ? I checked Deducer's source code and found quite a bit of JAVA... which parts would you recommend doing in JAVA ?

3) Can you point me to other packages, and less complex than Deducer that use JGR, so hopefully I can learn from their code?

4) Is there another way to add some menu to the standard R GUI, that would work on "all" OS (Linux, Windows, Mac OS X) ?

Thx for any suggestions, pointers and do-NOT-do-it shouts in adavance!


For your answer to 4 one can use gWidgetsWWW to create an interactive web page to gather the users input. It can be run on a server with RApache or standalone using the help page web server for R. Here is an example web page. (To run standalone, save this somewhere, say /tmp/test.R, and load with localServerStart("/tmp/test.R")

runSweave <- function(...) {
  ## replace with real deal
  ## point is l holds values:
  values <- sapply(l, svalue, simplify=FALSE)
  gmessage(message=sprintf("Run sweave using inputs %s and %s", values$one,values$two), parent=w)
}

runAbout <- function(...) {
  gmessage("A simple GUI for running a report", parent=w)
}

w <- gwindow("Write a report")
l <- list()

actions <- list(run=gaction(label="run",  handler=runSweave, parent=w),
                about=gaction(label="about", handler=runAbout, parent=w))

gmenu(actions, cont=w)

g <- ggroup(cont=w, horizontal=FALSE)
ghtml(boilerplate <- paste("Lorem ipsum dolor sit amet, consectetur adipisicing elit,",
                           "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
                           "Ut enim ad minim",
                           sep="</br>"),
      cont=g)

l$one <- gedit("Enter text here", cont=g)
ghtml(boilerplate, cont=g)
l$two <- gedit("Enter more text here", cont=g)

gstatusbar("thats it...", cont=g)
visible(w) <- TRUE


OK, I'm going to answer the 1st and the 4th one:

Ad 1. IMHO, it's not "reasonable" to create GUI for Sweave... If I'm writing a report, I'd like to do something like:

There were gathered \Sexpr{length(na.omit(x))} valid responses, 
with mean of \Sexpr{mean(x, na.rm = TRUE)} and 
standard deviation \Sexpr{sd(x, na.rm = TRUE)}.

<<qqplot, echo = FALSE, fig = TRUE>>==
qqplot(x)
qqnorm(x)
@

LyX already does that (though I use Emacs with ESS and AUCTeX). I mean, you can write a JAVA GUI and facilitate some features... but you must dazzle if you want to get noticed, otherwise, you're destined to invent what's already invented. But you can contribute... just... don't start from scratch without a good reason.

Ad 4. Yes, there is: RApache and/or RServe. You can mash-up R with some nifty JS library (like ExtJS) and do something like Jeroen Ooms did in his ggplot2/stockplot/lme4/IRT tool application(s). brew package is quite useful. There are drawbacks: you need server access, Internet access on the client, but it's cross-platform and server is a beast of a machine, so imagine what it be like to crunch some big data on desktop machine... server/cloud can do it in an eye-blink time.

Since I don't know how to write a single bloody thing in JAVA, HTML/CSS/JavaScript/PHP/MySQL/etc. with R is my weapon of choice.

So there...

Good luck!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜