Showing posts with label R miniUI packages. Show all posts
Showing posts with label R miniUI packages. Show all posts

Tuesday, September 17, 2019

R miniUI packages

How to use r miniUI packages

install.packages("miniUI")


> library("tidyverse", lib.loc="~/R/win-library/3.6")
-- Attaching packages --------------------------------------- tidyverse 1.2.1 --
v ggplot2 3.2.0     v purrr   0.3.2
v tibble  2.1.3     v dplyr   0.8.3
v tidyr   0.8.3     v stringr 1.4.0
v readr   1.3.1     v forcats 0.4.0
-- Conflicts ------------------------------------------ tidyverse_conflicts() --
x dplyr::filter() masks timeSeries::filter(), stats::filter()
x dplyr::lag()    masks timeSeries::lag(), stats::lag()
> library("rstudioapi", lib.loc="~/R/win-library/3.6")
> install.packages("miniUI", dependencies = FALSE)
Installing package into ‘C:/Users/ADMIN/Documents/R/win-library/3.6’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.6/miniUI_0.1.1.1.zip'
Content type 'application/zip' length 36579 bytes (35 KB)
downloaded 35 KB

package ‘miniUI’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
C:\Users\ADMIN\AppData\Local\Temp\RtmpuKDshc\downloaded_packages
> library("miniUI", lib.loc="~/R/win-library/3.6")
> miniTitleBar("My App",
+              left = miniTitleBarButton("prev", "Previous"),
+              right = miniTitleBarButton("next", "Next")
+ )
<div class="gadget-title">
  <h1>My App</h1>
  <button class="btn btn-default btn-sm action-button pull-left" id="prev" type="button">Previous</button>
  <button class="btn btn-default btn-sm action-button pull-right" id="next" type="button">Next</button>
</div>
> miniButtonBlock(
+     actionButton("reset", "Reset to defaults"),
+     actionButton("clear", "Clear all")
+ )
Error in actionButton("reset", "Reset to defaults") :
  could not find function "actionButton"
> library("shiny", lib.loc="~/R/win-library/3.6")
> miniButtonBlock(
+          actionButton("reset", "Reset to defaults"),
+          actionButton("clear", "Clear all") )
<div class="gadget-block-button gadget-block-button-top">
  <button id="reset" type="button" class="btn btn-default action-button">Reset to defaults</button>
  <button id="clear" type="button" class="btn btn-default action-button">Clear all</button>
</div>
> miniContentPanel(padding = 0,
+                  plotOutput("plot", height = "100%")
+ )
<div class="gadget-scroll">
  <div class="gadget-content">
    <div class="gadget-absfill" style="position: absolute; top:0px;right:0px;bottom:0px;left:0px;;">
      <div id="plot" class="shiny-plot-output" style="width: 100% ; height: 100%"></div>
    </div>
  </div>
</div>
> miniTabstripPanel(
+     miniTabPanel("Data", icon = icon("table"),
+                  selectInput("dataset", "Data set", ls("package:datasets"))),
+     miniTabPanel("Subset", icon = icon("sliders"),
+                  uiOutput("subset_ui")
+     )
+ )
<div class="gadget-tabs-content-container">
  <div class="tab-content">
    <div class="tab-pane active" data-value="Data" data-icon-class="fa fa-table" id="tab-9196-1">
      <div class="gadget-tabs-content-inner">
        <div class="form-group shiny-input-container">
          <label class="control-label" for="dataset">Data set</label>
          <div>
            <select id="dataset"><option value="ability.cov" selected>ability.cov</option>
<option value="airmiles">airmiles</option>
<option value="AirPassengers">AirPassengers</option>
<option value="airquality">airquality</option>
<option value="anscombe">anscombe</option>
<option value="attenu">attenu</option>
<option value="attitude">attitude</option>
<option value="austres">austres</option>
<option value="beaver1">beaver1</option>
<option value="beaver2">beaver2</option>
<option value="BJsales">BJsales</option>
<option value="BJsales.lead">BJsales.lead</option>
<option value="BOD">BOD</option>
<option value="cars">cars</option>
<option value="ChickWeight">ChickWeight</option>
<option value="chickwts">chickwts</option>
<option value="co2">co2</option>
<option value="CO2">CO2</option>
<option value="crimtab">crimtab</option>
<option value="discoveries">discoveries</option>
<option value="DNase">DNase</option>
<option value="esoph">esoph</option>
<option value="euro">euro</option>
<option value="euro.cross">euro.cross</option>
<option value="eurodist">eurodist</option>
<option value="EuStockMarkets">EuStockMarkets</option>
<option value="faithful">faithful</option>
<option value="fdeaths">fdeaths</option>
<option value="Formaldehyde">Formaldehyde</option>
<option value="freeny">freeny</option>
<option value="freeny.x">freeny.x</option>
<option value="freeny.y">freeny.y</option>
<option value="HairEyeColor">HairEyeColor</option>
<option value="Harman23.cor">Harman23.cor</option>
<option value="Harman74.cor">Harman74.cor</option>
<option value="Indometh">Indometh</option>
<option value="infert">infert</option>
<option value="InsectSprays">InsectSprays</option>
<option value="iris">iris</option>
<option value="iris3">iris3</option>
<option value="islands">islands</option>
<option value="JohnsonJohnson">JohnsonJohnson</option>
<option value="LakeHuron">LakeHuron</option>
<option value="ldeaths">ldeaths</option>
<option value="lh">lh</option>
<option value="LifeCycleSavings">LifeCycleSavings</option>
<option value="Loblolly">Loblolly</option>
<option value="longley">longley</option>
<option value="lynx">lynx</option>
<option value="mdeaths">mdeaths</option>
<option value="morley">morley</option>
<option value="mtcars">mtcars</option>
<option value="nhtemp">nhtemp</option>
<option value="Nile">Nile</option>
<option value="nottem">nottem</option>
<option value="npk">npk</option>
<option value="occupationalStatus">occupationalStatus</option>
<option value="Orange">Orange</option>
<option value="OrchardSprays">OrchardSprays</option>
<option value="PlantGrowth">PlantGrowth</option>
<option value="precip">precip</option>
<option value="presidents">presidents</option>
<option value="pressure">pressure</option>
<option value="Puromycin">Puromycin</option>
<option value="quakes">quakes</option>
<option value="randu">randu</option>
<option value="rivers">rivers</option>
<option value="rock">rock</option>
<option value="Seatbelts">Seatbelts</option>
<option value="sleep">sleep</option>
<option value="stack.loss">stack.loss</option>
<option value="stack.x">stack.x</option>
<option value="stackloss">stackloss</option>
<option value="state.abb">state.abb</option>
<option value="state.area">state.area</option>
<option value="state.center">state.center</option>
<option value="state.division">state.division</option>
<option value="state.name">state.name</option>
<option value="state.region">state.region</option>
<option value="state.x77">state.x77</option>
<option value="sunspot.month">sunspot.month</option>
<option value="sunspot.year">sunspot.year</option>
<option value="sunspots">sunspots</option>
<option value="swiss">swiss</option>
<option value="Theoph">Theoph</option>
<option value="Titanic">Titanic</option>
<option value="ToothGrowth">ToothGrowth</option>
<option value="treering">treering</option>
<option value="trees">trees</option>
<option value="UCBAdmissions">UCBAdmissions</option>
<option value="UKDriverDeaths">UKDriverDeaths</option>
<option value="UKgas">UKgas</option>
<option value="USAccDeaths">USAccDeaths</option>
<option value="USArrests">USArrests</option>
<option value="UScitiesD">UScitiesD</option>
<option value="USJudgeRatings">USJudgeRatings</option>
<option value="USPersonalExpenditure">USPersonalExpenditure</option>
<option value="uspop">uspop</option>
<option value="VADeaths">VADeaths</option>
<option value="volcano">volcano</option>
<option value="warpbreaks">warpbreaks</option>
<option value="women">women</option>
<option value="WorldPhones">WorldPhones</option>
<option value="WWWusage">WWWusage</option></select>
            <script type="application/json" data-for="dataset" data-nonempty="">{}</script>
          </div>
        </div>
      </div>
    </div>
    <div class="tab-pane" data-value="Subset" data-icon-class="fa fa-sliders" id="tab-9196-2">
      <div class="gadget-tabs-content-inner">
        <div id="subset_ui" class="shiny-html-output"></div>
      </div>
    </div>
  </div>
</div>
<div class="gadget-tabs-container">
  <ul class="nav gadget-tabs">
    <li class="active">
      <a href="#tab-9196-1" data-toggle="tab" data-value="Data">
        <i class=" fa fa-table fa-fw"></i>
        Data
      </a>
    </li>
    <li>
      <a href="#tab-9196-2" data-toggle="tab" data-value="Subset">
        <i class=" fa fa-sliders fa-fw"></i>
        Subset
      </a>
    </li>
  </ul>
</div>

Black-Scholes formula-R

 Black-Scholes formula-R > BlackScholes <- function(TypeFlag = c("c", "p"), S, X, Time, r, b, sigma) { TypeFla...