Robin
Robin

Reputation: 1

looking to run R GUI in R shiny server

Hope you all are doing good!

I am new to R shiny and no nothing about it(sorry) but i am trying my best to learn it. I have a R GUI ready with me which has all the widgets and buttons already, is there a way that i can host GUI in R shiny, if yes then can any one of you help me with that , My R file script name is NBAengine4.R. I really need your support here. thank you in advance!

Upvotes: 0

Views: 282

Answers (1)

Thomas Martin
Thomas Martin

Reputation: 686

Shiny is an R package that makes it easy to build interactive web applications (apps) straight from R. This lesson will get you started building Shiny apps right away.

If you still haven’t installed the Shiny package, open an R session, connect to the internet, and run

install.packages("shiny")

The Shiny package has eleven built-in examples that each demonstrate how Shiny works. Each example is a self-contained Shiny app.

The Hello Shiny example plots a histogram of R’s faithful dataset with a configurable number of bins. Users can change the number of bins with a slider bar, and the app will immediately respond to their input. You’ll use Hello Shiny to explore the structure of a Shiny app and to create your first app.

To run Hello Shiny, type:

library(shiny)
runExample("01_hello")

Structure of a Shiny App

Shiny apps are contained in a single script called app.R. The script app.R lives in a directory (for example, newdir/) and the app can be run with runApp("newdir").

app.R has three components:

1.) a user interface object

2.) a server function

3.) a call to the shinyApp function

The user interface (ui) object controls the layout and appearance of your app. The server function contains the instructions that your computer needs to build your app. Finally the shinyApp function creates Shiny app objects from an explicit UI/server pair.

One nice feature about single-file apps is that you can copy and paste the entire app into the R console, which makes it easy to quickly share code for others to experiment with. For example, if you copy and paste the code above into the R command line, it will start a Shiny app.

Running an App

Every Shiny app has the same structure: an app.R file that contains ui and server. You can create a Shiny app by making a new directory and saving an app.R file inside it. It is recommended that each app will live in its own unique directory.

You can run a Shiny app by giving the name of its directory to the function runApp. For example if your Shiny app is in a directory called my_app, run it with the following code:

library(shiny)
runApp("my_app")

Also go through this link for more info regarding shiny server,

https://shiny.rstudio.com/articles/shiny-server.html

Upvotes: 1

Related Questions