R Web Application Introduction

R web application introduction

An update, several years later:

What technology to use for integrating R into web apps depends upon the scale of what you are trying to accomplish.

For small, standalone web apps, Shiny is fast becoming the de facto standard. It is relatively easy to use, and there are paid support options.

For bigger projects, you are probably better off using whatever web framework you are comfortable with and then figuring out how to connect to R. (You can call R from the command line from any more-or-less any other software, and there are some slightly nicer interfaces to R such as rJava for Java apps.) This sounds a little vague, but for such projects the important decisions are based on "what does your company already use?" and "what do you need R for?"


Original answer:

There are lots of different ways of creating a web app with R. Most (if not all) are listed in the FAQ on R document.

If you want to use RApache, there's a presentation on the old RApache site that might be useful to get you started. Otherwise, RWui is very simple to use, but not so flexible (last time I used it, anyway), and rcom/StatConnector can be used to run R from your web server.

A web interface to an R program

R has its own web server, so you could do the whole thing within R. Then there's no need to bother with choosing a framework, or getting them to talk to each other and so on - just use an R framework:

http://cran.r-project.org/web/packages/Rook/index.html

If you don't like that for performance or other reasons, pretty much any framework will talk to R one way or another, so use what you are familiar with. I'd use Django and either call R via Rpy2 or run an Rserve process, but if you can program in PHP or Java then use a framework based on those languages. If you can't program in anything but R then either learn Python or use Rook.

Output of Shiny app is not rendered in Quarto

You are not getting the output because you are trying to render the shiny app on a website. While the shiny app needs to run the code of the server part to compute the output and to print the output in the textOutput, but the website is static and can not run any code and will not respond to any kind of user input.

So when you are trying to render the shiny app on the website, you will only see the static part of your app (the HTML components and CSS styling) but not any interactive part of the shiny app.

Quoting from this answer on the Github discussion

The Quarto website is ultimately a static website - it won't be responding to user input or running any R code. You can embed a shiny app into a qmd that you render in the rstudio IDE and it'll work just fine because the shiny app is running in a session on your computer. Website hosting services like quarto-pub, netlify, and gh-pages will only be serving up the html pages of the site, not running the code necessary to operate the shiny app in response to user input.

One workaround is to put an iframe into your website that points that page of the website to your shiny app as hosted on a shiny server like shinyapps.io

Show the console output from R to be shown in an html page in an web application

I can recommend you the package shiny.
Its very good for returning plots and tables, but not so much for R-concole output.
You can have a look here:
http://rstudio.github.io/shiny/tutorial/#hello-shiny

how to open a link in shiny

I guess you just wanted a resizable browser tab popup, for this you edit the JS and add resizable argument:

library(shiny)
ui <- fluidPage(shiny::fluidRow(shiny::actionButton(inputId='ab1',
label="click here", value = "Open popup",onclick ="window.open('http://google.com','_blank','resizable,height=260,width=370')")))

server <- function(input, output) {}
shinyApp(ui, server)

Create link to the other part of the Shiny app

What you are looking for is an HTML anchor tag.
You could for example create an anchor to your distPlot2 using:

column(12,p(HTML("intro text <a href='#distPlot2'>Go to plot 2</a> intro text ")))

You can replace what is after the # by the id any HTML element you want to jump to.



Related Topics



Leave a reply



Submit