LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Rpad - a web interface to identify() ? (https://www.linuxquestions.org/questions/programming-9/rpad-a-web-interface-to-identify-509772/)

StargateSteve 12-12-2006 01:23 PM

Rpad - a web interface to identify() ?
 
View As Web Page

i have a function like this:
# show a plot and run a script when the user clicks on a plot,
# where the script arguments correspond to the user-selected point.
blah <- function(x, y) {
plot(y~x)
n <- identify(x=x, y=y)
com <- system(command=paste("bleh", names(y)[n]))
}

i would like to do this via a web page instead of x11() etc. eg:
1) a user clicks on an image in their web browser
2) the i,j coordinate is sent to the server
3) a single R process determines the nearest data point
4) the server sends a new page to the client, based on attributes
of the selected data point

i've browsed the R web interface options and frankly don't know which
to pick, or maybe they are all overkill for what i am trying to
accomplish? perhaps the easiest thing to do is use ismap to capture
the i,j coords, the receiving cgi script connects to an R process for
the data lookup, and then responds to the browsing client
appropriately. the data set involved is very large, so i'd need a
single R process sitting there waiting for such queries in order to
avoid initialize&load time - this is the part i am particularly
unclear how to do.

any ideas/suggestions/guidance on the best approach would be much
appreciated. thank you.

95se 12-13-2006 08:07 AM

Perhaps you could consider this; chose a language to write your CGI script in, like Python or Perl. Next, see if there are any FastCGI modules/classes/libraries for it (unless you chose something really obscure, there probably will be). Now, in the FastCGI script itself you can start by creating an R process, feeding it what you need and just keeping it open for all requests. You'll have to handle how all the parameters are passed (ex. GET or POST). Now, use Javascript to get the mouse click co-ordinates. With these either (re)load the CGI script or, use AJAX, and let the CGI script handle only the generation of the graph.

StargateSteve 12-14-2006 01:04 PM

I would do that, but here's the rest of the setup:

I have an HTML document using the ISMAP argument with the img tag, so the I,J (client-side, image coords) are passed to the server. There, I have a C++ program extracting the I,J from the query string, and need to use identify() in order to get the real X,Y from the image.

The image is thousands of data points graphed out.

I want the user to be able to click on or near a data point, and have the server send them to the HTML page for that data point.


The other thing: the image might change every few minutes, so I can't just create a several MB HTML imagemap.


All times are GMT -5. The time now is 03:30 AM.