Professional Documents
Culture Documents
Suppose that you create a prediction algorithm, with shiny you can very easily create web input
form that calls R and thus your prediction algorithm and displays the results.
Using Shiny, the time to create simple, yet powerful, web-based interactive data products in R is
minimized.
Shiny is made by the fine folks at R Studio.
However, it lacks the flexibility of full featured (and more complex) solutions. -
Shiny doesn't really require it, but as with all web programming, a little knowledge of html, css
and js is very helpful
There are too many tutorials online to count for getting basic proficiency in these topics to count.
Shiny uses bootstrap (no relation to the statistics bootstrap) style, which (to me) seems to look
nice and renders well on mobile platforms
html gives a web page structure and sectioning as well as markup instructions
css gives the style
js for interactivity
-
-
-
Creating any solution requiring fairly deep knowledge of web client/server programming
OpenCPU by J erome Ooms, is a really neat project providing an API for calling R from web
documents
And he even hosts an OpenCPU server, but you can create your own -
You created a novel prediction algorithm to predict risk for developing diabetes.
You want to create a web site so that users can input the relevant predictors and obtain their
prediction.
Your prediction algorithm (ok, so you're not going to be saving the world with this one)
You're hoping patients and caregivers will be able to enter their data and, if needed, take
preventative measures.
-
ui . R
shi nyUI ( pageWi t hSi debar (
header Panel ( "I l l ust r at i ng mar kup") ,
si debar Panel (
h1( ' Si debar panel ' ) ,
h1( ' H1 t ext ' ) ,
h2( ' H2 Text ' ) ,
h3( ' H3 Text ' ) ,
h4( ' H4 Text ' )
) ,
mai nPanel (
h3( ' Mai n Panel t ext ' ) ,
code( ' some code' ) ,
p( ' some or di nar y t ext ' )
)
) )
shi nyUI ( pageWi t hSi debar (
header Panel ( "I l l ust r at i ng i nput s") ,
si debar Panel (
numer i cI nput ( ' i d1' , ' Numer i c i nput , l abel ed i d1' , 0, mi n =0, max = 10, st ep =1) ,
checkboxGr oupI nput ( "i d2", "Checkbox",
c( "Val ue 1" = "1",
"Val ue 2" = "2",
"Val ue 3" = "3") ) ,
dat eI nput ( "dat e", "Dat e: ")
) ,
mai nPanel (
)
) )
mai nPanel (
h3( ' I l l ust r at i ng out put s' ) ,
h4( ' You ent er ed' ) ,
ver bat i mText Out put ( "oi d1") ,
h4( ' You ent er ed' ) ,
ver bat i mText Out put ( "oi d2") ,
h4( ' You ent er ed' ) ,
ver bat i mText Out put ( "odat e")
)
shi nySer ver (
f unct i on( i nput , out put ) {
out put $oi d1 <- r ender Pr i nt ( {i nput $i d1})
out put $oi d2 <- r ender Pr i nt ( {i nput $i d2})
out put $odat e <- r ender Pr i nt ( {i nput $dat e})
}
)
shi nyUI (
pageWi t hSi debar (
# Appl i cat i on t i t l e
header Panel ( "Di abet es pr edi ct i on") ,
si debar Panel (
numer i cI nput ( ' gl ucose' , ' Gl ucose mg/ dl ' , 90, mi n = 50, max =200, st ep =5) ,
submi t But t on( ' Submi t ' )
) ,
mai nPanel (
h3( ' Resul t s of pr edi ct i on' ) ,
h4( ' You ent er ed' ) ,
ver bat i mText Out put ( "i nput Val ue") ,
h4( ' Whi ch r esul t ed i n a pr edi ct i on of ' ) ,
ver bat i mText Out put ( "pr edi ct i on")
)
)
)
di abet esRi sk <- f unct i on( gl ucose) gl ucose / 200
shi nySer ver (
f unct i on( i nput , out put ) {
out put $i nput Val ue <- r ender Pr i nt ( {i nput $gl ucose})
out put $pr edi ct i on <- r ender Pr i nt ( {di abet esRi sk( i nput $gl ucose) })
}
)
Let's build an example with an image
How about we create a histogram of data
Put a slider on so that the user has to guess the mean
The quickest way is to send (or put on github or gist or dropbox or whatever) someone the app
directory and they can then call r unApp
You could create an R package and create a wrapper that calls r unApp
Another option is to run a shiny server