React (or React Js) is a declarative, component-based JS library to build SPA(single page applications) which was created by Jordan Walke, a software engineer at Facebook. It is flexible and can be used in a variety of projects.
Fundamentals of Database Systems Questions and AnswersOXUS 20
Fundamentals of Database Systems questions and answers with explanation for fresher's and experienced for interview, competitive examination and entrance test.
React (or React Js) is a declarative, component-based JS library to build SPA(single page applications) which was created by Jordan Walke, a software engineer at Facebook. It is flexible and can be used in a variety of projects.
Fundamentals of Database Systems Questions and AnswersOXUS 20
Fundamentals of Database Systems questions and answers with explanation for fresher's and experienced for interview, competitive examination and entrance test.
I've been working a lot with React lately and thought it would be a good idea to share what I've learned with the group.
During this talk we'll take a look at Facebook's React library while drawing comparisons to frameworks like Angular. We'll see how we can use React and friends to create a fast and efficient single page app. Attendees are expected to have some familiarity with ES6/ES7 since we the codebase we will be looking at leverages features from the spec.
What we'll be taking a look at:
• React
• React Router
• Redux
• Redux Sagas
• Webpack
• Babel
This presentation is based on the first chapter of our textbook Fundamentals of Web Development. The book is published by Addison-Wesley. It can be purchased via http://www.amazon.com/Fundamentals-Web-Development-Randy-Connolly/dp/0133407152.
This book is intended to be used as a textbook on web development suitable for intermediate to upper-level computing students. It may also be of interest to a non-student reader wanting a single book that encompasses the entire breadth of contemporary web development.
This book will be the first in what will hopefully be a textbook series. Each book in the series will have the same topics and coverage but each will use a different web development environment. The first book in the series will use PHP.
To learn more about the book, visit http://www.funwebdev.com.
Come see how easy it is to build fast, accurate, and responsive web UIs using the React library. Even if you’ve never written Javascript before, React’s straightforward syntax can get you started with your UI project quickly. In this session, you’ll learn about React’s declarative syntax and state representation, explore some of the basic components that are used to build sophisticated UIs, and leave with a foundational application you can continue to build on.
Power BI Tutorial For Beginners | Power BI Tutorial | Power BI Demo | Power B...Edureka!
( Power BI Training - https://www.edureka.co/power-bi-training )
This Edureka videoon "Power BI Tutorial" will provide you with the fundamental knowledge on Power BI (Blog: https://goo.gl/uFTDU3). Below are the topics covered in this tutorial:
1. Why do we need Business Intelligence?
2. What is Self Service Business Intelligence?
3. Why Power BI?
4. What is Power BI?
5. Demo: Report and Dashboard Creation
This Presentation is about NoSQL which means Not Only SQL. This presentation covers the aspects of using NoSQL for Big Data and the differences from RDBMS.
ESOFT Metro Campus - Diploma in Software Engineering - (Module IV) Database Concepts
(Template - Virtusa Corporate)
Contents:
Introduction to Databases
Data
Information
Database
Database System
Database Applications
Evolution of Databases
Traditional Files Based Systems
Limitations in Traditional Files
The Database Approach
Advantages of Database Approach
Disadvantages of Database Approach
Database Management Systems
DBMS Functions
Database Architecture
ANSI-SPARC 3 Level Architecture
The Relational Data Model
What is a Relation?
Primary Key
Cardinality and Degree
Relationships
Foreign Key
Data Integrity
Data Dictionary
Database Design
Requirements Collection and analysis
Conceptual Design
Logical Design
Physical Design
Entity Relationship Model
A mini-world example
Entities
Relationships
ERD Notations
Cardinality
Optional Participation
Entities and Relationships
Attributes
Entity Relationship Diagram
Entities
ERD Showing Weak Entities
Super Type / Sub Type Relationships
Mapping ERD to Relational
Map Regular Entities
Map Weak Entities
Map Binary Relationships
Map Associated Entities
Map Unary Relationships
Map Ternary Relationships
Map Supertype/Subtype Relationships
Normalization
Advantages of Normalization
Disadvantages of Normalization
Normal Forms
Functional Dependency
Purchase Order Relation in 0NF
Purchase Order Relation in 1NF
Purchase Order Relations in 2NF
Purchase Order Relations in 3NF
Normalized Relations
BCNF – Boyce Codd Normal Form
Structured Query Language
What We Can Do with SQL ?
SQL Commands
SQL CREATE DATABASE
SQL CREATE TABLE
SQL DROP
SQL Constraints
SQL NOT NULL
SQL PRIMARY KEY
SQL CHECK
SQL FOREIGN KEY
SQL ALTER TABLE
SQL INSERT INTO
SQL INSERT INTO SELECT
SQL SELECT
SQL SELECT DISTINCT
SQL WHERE
SQL AND & OR
SQL ORDER BY
SQL UPDATE
SQL DELETE
SQL LIKE
SQL IN
SQL BETWEEN
SQL INNER JOIN
SQL LEFT JOIN
SQL RIGHT JOIN
SQL UNION
SQL AS
SQL Aggregate Functions
SQL Scalar functions
SQL GROUP BY
SQL HAVING
Database Administration
SQL Database Administration
This small ppt is introduction to R Shiny Package .A web application framework for R that allows you to turn your
data into an interactive web App.
You can easily integrate R with webpage. Suppose you want your web page run machine learning algorithms like random forest, SVM etc and display summary of the model with the flexibility of selecting inputs from user. Shiny can do it very easily.
I've been working a lot with React lately and thought it would be a good idea to share what I've learned with the group.
During this talk we'll take a look at Facebook's React library while drawing comparisons to frameworks like Angular. We'll see how we can use React and friends to create a fast and efficient single page app. Attendees are expected to have some familiarity with ES6/ES7 since we the codebase we will be looking at leverages features from the spec.
What we'll be taking a look at:
• React
• React Router
• Redux
• Redux Sagas
• Webpack
• Babel
This presentation is based on the first chapter of our textbook Fundamentals of Web Development. The book is published by Addison-Wesley. It can be purchased via http://www.amazon.com/Fundamentals-Web-Development-Randy-Connolly/dp/0133407152.
This book is intended to be used as a textbook on web development suitable for intermediate to upper-level computing students. It may also be of interest to a non-student reader wanting a single book that encompasses the entire breadth of contemporary web development.
This book will be the first in what will hopefully be a textbook series. Each book in the series will have the same topics and coverage but each will use a different web development environment. The first book in the series will use PHP.
To learn more about the book, visit http://www.funwebdev.com.
Come see how easy it is to build fast, accurate, and responsive web UIs using the React library. Even if you’ve never written Javascript before, React’s straightforward syntax can get you started with your UI project quickly. In this session, you’ll learn about React’s declarative syntax and state representation, explore some of the basic components that are used to build sophisticated UIs, and leave with a foundational application you can continue to build on.
Power BI Tutorial For Beginners | Power BI Tutorial | Power BI Demo | Power B...Edureka!
( Power BI Training - https://www.edureka.co/power-bi-training )
This Edureka videoon "Power BI Tutorial" will provide you with the fundamental knowledge on Power BI (Blog: https://goo.gl/uFTDU3). Below are the topics covered in this tutorial:
1. Why do we need Business Intelligence?
2. What is Self Service Business Intelligence?
3. Why Power BI?
4. What is Power BI?
5. Demo: Report and Dashboard Creation
This Presentation is about NoSQL which means Not Only SQL. This presentation covers the aspects of using NoSQL for Big Data and the differences from RDBMS.
ESOFT Metro Campus - Diploma in Software Engineering - (Module IV) Database Concepts
(Template - Virtusa Corporate)
Contents:
Introduction to Databases
Data
Information
Database
Database System
Database Applications
Evolution of Databases
Traditional Files Based Systems
Limitations in Traditional Files
The Database Approach
Advantages of Database Approach
Disadvantages of Database Approach
Database Management Systems
DBMS Functions
Database Architecture
ANSI-SPARC 3 Level Architecture
The Relational Data Model
What is a Relation?
Primary Key
Cardinality and Degree
Relationships
Foreign Key
Data Integrity
Data Dictionary
Database Design
Requirements Collection and analysis
Conceptual Design
Logical Design
Physical Design
Entity Relationship Model
A mini-world example
Entities
Relationships
ERD Notations
Cardinality
Optional Participation
Entities and Relationships
Attributes
Entity Relationship Diagram
Entities
ERD Showing Weak Entities
Super Type / Sub Type Relationships
Mapping ERD to Relational
Map Regular Entities
Map Weak Entities
Map Binary Relationships
Map Associated Entities
Map Unary Relationships
Map Ternary Relationships
Map Supertype/Subtype Relationships
Normalization
Advantages of Normalization
Disadvantages of Normalization
Normal Forms
Functional Dependency
Purchase Order Relation in 0NF
Purchase Order Relation in 1NF
Purchase Order Relations in 2NF
Purchase Order Relations in 3NF
Normalized Relations
BCNF – Boyce Codd Normal Form
Structured Query Language
What We Can Do with SQL ?
SQL Commands
SQL CREATE DATABASE
SQL CREATE TABLE
SQL DROP
SQL Constraints
SQL NOT NULL
SQL PRIMARY KEY
SQL CHECK
SQL FOREIGN KEY
SQL ALTER TABLE
SQL INSERT INTO
SQL INSERT INTO SELECT
SQL SELECT
SQL SELECT DISTINCT
SQL WHERE
SQL AND & OR
SQL ORDER BY
SQL UPDATE
SQL DELETE
SQL LIKE
SQL IN
SQL BETWEEN
SQL INNER JOIN
SQL LEFT JOIN
SQL RIGHT JOIN
SQL UNION
SQL AS
SQL Aggregate Functions
SQL Scalar functions
SQL GROUP BY
SQL HAVING
Database Administration
SQL Database Administration
This small ppt is introduction to R Shiny Package .A web application framework for R that allows you to turn your
data into an interactive web App.
You can easily integrate R with webpage. Suppose you want your web page run machine learning algorithms like random forest, SVM etc and display summary of the model with the flexibility of selecting inputs from user. Shiny can do it very easily.
This presentation is a part of the COP2272C college level course taught at the Florida Polytechnic University located in Lakeland Florida. The purpose of this course is to introduce students to the C++ language and the fundamentals of object orientated programming..
The course is one semester in length and meets for 2 hours twice a week. The Instructor is Dr. Jim Anderson.
Introduction to interactive data visualisation using R Shinyanamarisaguedes
Shiny is an R library for building interactive webapps. Shiny allows rapid prototyping and quick production of dashboards and interactive data visualisations. This is especially important in situations where putting a real data-driven prototype in the hands of the end user allows for better refining of requirements before passing off to a web development team. This allows to speed up the delivery process and reducing the dependencies on other teams.
Code and solution to exercises available on github: https://github.com/amguedes/ShinySeminar
Redux and context api with react native app introduction, use cases, implemen...Katy Slemon
Learn how to build an app using Redux and Context API with React Native. In this tutorial, we will compare and learn how to Implement both these techs.
A progressive web app (PWA) delivers an app-like experience through your mobile phone’s browser but has the same flexibility and gestures as a native application. Because they are powered by mobile browsers, they are not particular to any one device, meaning developers no longer need to write separate code for Android and Apple devices.
Markdown tutorial how to add markdown to rails app using redcarpet and codera...Katy Slemon
In this Markdown tutorial, we will add Markdown to Rails app using Redcarpet and Coderay gems. Clone the github repository and play around with the code.
The Roman Empire A Historical Colossus.pdfkaushalkr1407
The Roman Empire, a vast and enduring power, stands as one of history's most remarkable civilizations, leaving an indelible imprint on the world. It emerged from the Roman Republic, transitioning into an imperial powerhouse under the leadership of Augustus Caesar in 27 BCE. This transformation marked the beginning of an era defined by unprecedented territorial expansion, architectural marvels, and profound cultural influence.
The empire's roots lie in the city of Rome, founded, according to legend, by Romulus in 753 BCE. Over centuries, Rome evolved from a small settlement to a formidable republic, characterized by a complex political system with elected officials and checks on power. However, internal strife, class conflicts, and military ambitions paved the way for the end of the Republic. Julius Caesar’s dictatorship and subsequent assassination in 44 BCE created a power vacuum, leading to a civil war. Octavian, later Augustus, emerged victorious, heralding the Roman Empire’s birth.
Under Augustus, the empire experienced the Pax Romana, a 200-year period of relative peace and stability. Augustus reformed the military, established efficient administrative systems, and initiated grand construction projects. The empire's borders expanded, encompassing territories from Britain to Egypt and from Spain to the Euphrates. Roman legions, renowned for their discipline and engineering prowess, secured and maintained these vast territories, building roads, fortifications, and cities that facilitated control and integration.
The Roman Empire’s society was hierarchical, with a rigid class system. At the top were the patricians, wealthy elites who held significant political power. Below them were the plebeians, free citizens with limited political influence, and the vast numbers of slaves who formed the backbone of the economy. The family unit was central, governed by the paterfamilias, the male head who held absolute authority.
Culturally, the Romans were eclectic, absorbing and adapting elements from the civilizations they encountered, particularly the Greeks. Roman art, literature, and philosophy reflected this synthesis, creating a rich cultural tapestry. Latin, the Roman language, became the lingua franca of the Western world, influencing numerous modern languages.
Roman architecture and engineering achievements were monumental. They perfected the arch, vault, and dome, constructing enduring structures like the Colosseum, Pantheon, and aqueducts. These engineering marvels not only showcased Roman ingenuity but also served practical purposes, from public entertainment to water supply.
Model Attribute Check Company Auto PropertyCeline George
In Odoo, the multi-company feature allows you to manage multiple companies within a single Odoo database instance. Each company can have its own configurations while still sharing common resources such as products, customers, and suppliers.
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
The French Revolution, which began in 1789, was a period of radical social and political upheaval in France. It marked the decline of absolute monarchies, the rise of secular and democratic republics, and the eventual rise of Napoleon Bonaparte. This revolutionary period is crucial in understanding the transition from feudalism to modernity in Europe.
For more information, visit-www.vavaclasses.com
The Art Pastor's Guide to Sabbath | Steve ThomasonSteve Thomason
What is the purpose of the Sabbath Law in the Torah. It is interesting to compare how the context of the law shifts from Exodus to Deuteronomy. Who gets to rest, and why?
Synthetic Fiber Construction in lab .pptxPavel ( NSTU)
Synthetic fiber production is a fascinating and complex field that blends chemistry, engineering, and environmental science. By understanding these aspects, students can gain a comprehensive view of synthetic fiber production, its impact on society and the environment, and the potential for future innovations. Synthetic fibers play a crucial role in modern society, impacting various aspects of daily life, industry, and the environment. ynthetic fibers are integral to modern life, offering a range of benefits from cost-effectiveness and versatility to innovative applications and performance characteristics. While they pose environmental challenges, ongoing research and development aim to create more sustainable and eco-friendly alternatives. Understanding the importance of synthetic fibers helps in appreciating their role in the economy, industry, and daily life, while also emphasizing the need for sustainable practices and innovation.
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
Operation “Blue Star” is the only event in the history of Independent India where the state went into war with its own people. Even after about 40 years it is not clear if it was culmination of states anger over people of the region, a political game of power or start of dictatorial chapter in the democratic setup.
The people of Punjab felt alienated from main stream due to denial of their just demands during a long democratic struggle since independence. As it happen all over the word, it led to militant struggle with great loss of lives of military, police and civilian personnel. Killing of Indira Gandhi and massacre of innocent Sikhs in Delhi and other India cities was also associated with this movement.
2. Shiny is an R package that makes it easy to build interactive web applications (apps) straight from R.
runExample("01_hello") # a histogram
Lesson 1
3. 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.
4. Structure of a Shiny App
Shiny apps have two components:
a user-interface (ui) script: controls the
layout and appearance of your app. It is
defined in a source script named ui.R.
The server.R script :contains the
instructions that your computer needs to
build your app.
5.
6.
7. At one level, the Hello Shiny server.R script is very simple. The
script does some calculations and then plots a histogram with the
requested number of bins.
most of the script is wrapped in a call to renderPlot:
1) It is "reactive" and therefore should re-execute automatically when
inputs change
2) Its output type is a plot
8.
9. Your Turn
Create a new directory named App-1 in your working directory. Then
copy and paste the ui.R and server.R scripts above into your
directory (the scripts from Hello Shiny).
Launch your app by running runApp("App-1"). Then click escape
and make some changes to your app:
1. Change the title from “Hello Shiny!” to “Hello World!”.
2. Set the minimum value of the slider bar to 5.
3. Change the histogram color from "darkgray" to "skyblue".
10.
11. Lesson 2
With will learn:
1. create a user-interface with fluidPage, titlePanel and sidebarLayout
2. create an HTML element with one of Shiny’s tag functions
3. set HTML tag attributes in the arguments of each tag function
4. add an element to your web page by passing it
to titlePanel, sidebarPanel or mainPanel
5. add multiple elements to each panel by separating them with a
comma
6. add images by placing your image in a folder labeled www within
your Shiny app directory and then calling the img function
12. Build a user-interface
• will show you how to build a user-interface for your app. You will
learn how to lay out the user-interface and then add text, images
and other HTML elements to your Shiny app.
13. • Shiny ui.R scripts use the function fluidPage to create a display that
automatically adjusts to the dimensions of your user’s browser
window.
ui.R script creates a user-interface that has a title panel and then a
sidebar layout, which includes a sidebar panel and a main panel.
14.
15. Title Panel and sidebar Layout are the two most popular
elements to add to fluid Page.
Sidebar Layout always takes two arguments:
1. sidebarPanel function output
2. mainPanel function output
16. • The sidebar panel will appear on the left side of your app by default.
You can move it to the right side by giving sidebar Layout the
optional argument position = "right".
17.
18. titlePanel and sidebarLayout create a basic layout for your Shiny
app, but you can also create more advanced layouts. You can
use navbarPage to give your app a multi-page user-interface that
includes a navigation bar. Or you can use fluidRow and column to
build your layout up from a grid system.
You can add content to your Shiny app by placing it inside
a *Panel function.
For example, The words “sidebar panel” appear in the sidebar panel,
because we added the string to the sidebarPanel function,
e.g sidebarPanel("sidebar panel"). The same is true for the text in the
title panel and the main panel.
19. To add more advanced content, use one of Shiny’s HTML tag functions. These
functions parallel common HTML5 tags.
HTML Content
20. Headers
To create a header element:
1. select a header function (e.g., h1 or h5)
2. give it the text you want to see in the header
21.
22. the effect with align = "center", as in h6("Episode IV", align = "center").
26. Images
• To insert an image, give the img function the name of your image file
as the src argument (e.g.,img(src = "my_image.png")).
27.
28. LESSON 3
Add control widgets
This lesson will show you how to add control widgets to
your Shiny apps.
widget :A web element that your users can interact with.
Widgets provide a way for your users to send messages
to the Shiny app
Shiny widgets collect a value from your user.
When a user changes the widget, the value will change
as well.
30. The standard Shiny widgets are:
function widget
actionButton Action Button
checkboxGroupInput A group of check boxes
checkboxInput A single check box
dateInput A calendar to aid date selection
dateRangeInput
A pair of calendars for selecting a date
range
fileInput A file upload control wizard
helpText
Help text that can be added to an input
form
numericInput A field to enter numbers
radioButtons A set of radio buttons
selectInput A box with choices to select from
sliderInput A slider bar
submitButton A submit button
textInput A field to enter text
31. Adding widgets
Each widget function requires several arguments. The first
two arguments for each widget are
1. A Name for the widget. The user will not see this
name, but you can use it to access the widget’s value.
The name should be a character string.
2. A label. This label will appear with the widget in your
app. It should be a character string, but it can be an
empty string "".
32.
33.
34. LESSON 4
Display reactive output
You will learn :
created your first reactive Shiny app.
use an *Output function in the ui.R script to place reactive objects in
your Shiny app.
use a render* function in the server.R script to tell Shiny how to build
your objects
surround R expressions by braces, {}, in each render* function
save your render* expressions in the output list, with one entry for
each reactive object in your app.
create reactivity by including an input value in a render* expression
35. Steps:
Create a folder in your working directory named
census-app. This is where we’ll save the ui.R and server.R.
You can create reactive output with a two step process.
1) Add an R object to your user-interface with ui.R.
2) Tell Shiny how to build the object in server.R. The
object will be reactive if the code that builds it calls a
widget value.
36. Step 1: Add an R object to the UI
• Shiny provides a family of functions that turn R objects into output
for your user-interface. Each function creates a specific type of
output.
37. the ui.R file below uses textOutput to add a reactive line of text to the
main panel of the
Notice
that textOutput takes
an argument, the
character string
“text1”. Each of
the *Output functions
require a single
argument: a character
string that Shiny will
use as the name of
your reactive element.
Your users will not see
this name, but you will
use it later.
38. Step 2: Provide R code to build the object.
The code should go in the unnamed function that
appears inside shinyServer in your server.R script.
it builds a list-like object named output that contains all of
the code needed to update the R objects in your app.
Each R object needs to have its own entry in the list.
The element name should match the name of the
reactive element that you created in ui.R.
39. You do not need to arrange for the unnamed function to return output in its
last line of code. R will automatically update output through reference class
semantics.
Each entry to output should contain the output of one of
Shiny’s render* functions.
Each render* function takes a single argument: an R expression surrounded
by braces, {}. The expression can be one simple line of text, or it can involve
many lines of code, as if it were a complicated function call.
Think of this R expression as a set of instructions that you give Shiny to
store for later. Shiny will run the instructions when you first launch your app,
and then Shiny will re-run the instructions every time it needs to update your
object.
For this to work, your expression should return the object you have in mind
(a piece of text, a plot, a data frame, etc). You will get an error if the
expression does not return an object, or if it returns the wrong type of object.
40.
41. When you run the server.R script, the Shiny app will display “You have
selected this” in the main panel. However, the text will not be reactive.
It will not change even if you manipulate the widgets of your app.
42. Use widget values
• You can make the text reactive by asking Shiny to call a widget
value when it builds the text.
• Shiny will automatically make an object reactive if the object uses
an input value
• When a user changes a widget, Shiny will rebuild all of the outputs
that depend on the widget, using the new value of the widget as it
.goes
43.
44. LESSON 5
Use R scripts and data
This lesson will show:
how to load data, R Scripts, and packages to use in your
Shiny apps.
Along the way, you will build a sophisticated app that
visualizes US Census data
45. counties.rds
counties.rds is a dataset of demographic data for each
county in the United States, collected with
the UScensus2010 R package.
Once you have it’s file :
1. Create a new folder named data in your census-
app directory.
2. Move counties.rds into the data folder.
46. The dataset in counties.rds contains
the name of each county in the United States
the total population of the county.
the percent of residents in the county who are white,
black, hispanic, or asian
47. helpers.R
helpers.R is an R script that can help you make
choropleth map is a map that uses color to display the
regional variation of a variable. e choropleth map.
helpers.R will create percent_map, a function designed
to map the data in counties.rds.
helpers.R uses the maps and mapproj packages in R.
Save helpers.R inside your census-app directory.
48. The percent_map function in helpers.R takes five arguments:
Argument Input
var
a column vector from
the counties.rds dataset
color
any character string you see in the
output of colors()
legend.title
A character string to use as the title of
the plot’s legend
max
A parameter for controlling shade
range (defaults to 100)
min
A parameter for controlling shade
range (defaults to 0)
You can use percent_map at the command line to plot the counties data as a
choropleth map
49.
50. Loading files and file paths
• Since you saved helpers.R in the same directory as server.R, you
can ask Shiny to load it with.
• Since you saved counties.rds in a sub-directory (named data) of the
directory that server.R is in, you can load it with.
• You can load the maps and mapproj packages in the normal way
with
51. Execution
Shiny will execute all of these commands if you
place them in your server.R script.
where you place them in server.R will determine
how many times they are run (or re-run), which
will in turn affect the performance of your app.
Shiny will run some sections of server.R more
often than others.
52. Shiny will run the whole script the first time you call runApp .This causes
Shiny to execute shinyServer.
shinyServer then gives Shiny the unnamed function in its first argument.
53. Shiny saves the unnamed function until a new user arrives.
Each time a new user visits your app, Shiny runs the unnamed
function again, one time. The function helps Shiny build a distinct set of
reactive objects for each user.
54. As users change widgets, Shiny will re-run the R expressions assigned
to each reactive object. If your user is very active, these expressions
may be re-run many, many times a second.
55. we’ve learned so far:
The server.R script is run once, when you launch your
app
The unnamed function inside shinyServer is run
once each time a user visits your app
The R expressions inside render* functions are run many
times. Shiny runs them once each time a user changes a
widget.
59. LESSON 6
Use reactive expressions
You can make your apps faster by modularizing your code with reactive
expressions.
A reactive expression takes input values, or values from other
reactive expressions, and returns a new value
Reactive expressions save their results, and will only re-calculate if
their input has changed
Create reactive expressions with reactive({ })
Call reactive expressions with the name of the expression followed
by parentheses ()
Only call reactive expressions from within other reactive expressions
or render* functions
60. • Shiny apps wow your users by running fast, instantly fast. But what if
your app needs to do a lot of slow computation?
• This lesson will show you how to streamline your Shiny apps with
reactive expressions.
• Reactive expressions let you control which parts of your app update
when, which prevents unnecessary work.
To get started:
1. Create a new folder named stockVis in your working directory.
2. Download the following files and place them
inside stockVis: ui.R, server.R, and helpers.R.
3. Launch the app with runApp("stockVis")
61.
62. StockVis relies heavily on two functions from
the quantmod package:
It uses getSymbols to download financial data straight
into R from websites like Yahoo finance and the Federal
Reserve Bank of St. Louis.
It uses chartSeries to display prices in an attractive
chart.
StockVis also relies on an R script named helpers.R,
which contains a function that adjusts stock prices for
inflation.
63. Streamline computation
• Examine what will happen when you click “Plot y axis on the log
scale.” The value of input$log will change, which will cause the
entire expression in renderPlot to re-run:
64. Each time renderPlot re-runs
it re-fetches the data from Yahoo finance with getSymbols, and
it re-draws the chart with the correct axis.
This is not good, because you do not need to re-fetch the data to re-
draw the plot. In fact, Yahoo finance will cut you off if you re-fetch your
data too often (because you begin to look like a bot). But more
importantly, re-running getSymbols is unnecessary work, which can
slow down your app and consume server bandwidth.
65. Reactive expressions
You can limit what gets re-run during a reaction with reactive expr
A reactive expression is an R expression that uses widget input and
returns a value. The reactive expression will update this value
whenever the original widget changes.
For example, here’s a reactive expression that uses the widgets of
stockVis to fetch data from Yahoo
66. • When you run the expression, it will run getSymbols and return the
results, a data frame of price data. You can use the expression to
access price data in renderPlot by calling dataInput().
67. Reactive expressions are a bit smarter than regular R functions.
They cache their values and know when their values have become
outdated. What does this mean? The first time that you run a
reactive expression, the expression will save its result in your
computer’s memory. The next time you call the reactive expression,
it can return this saved result without doing any computation (which
will make your app fast
The reactive expression will only return the saved result if it knows
that the result is up-to-date. If the reactive expression has learned
that the result is obsolete (because a widget has changed), the
expression will recalculate the result. It then returns the new result
and saves a new copy. The reactive expression will use this new
copy until it too becomes out of date. er).
68. Let’s summarize this behavior
• A reactive expression saves its result the first time you run it.
• The next time the reactive expression is called, it checks if the saved
value has become out of date (i.e., whether the widgets it depends
on have changed).
• If the value is out of date, the reactive object will recalculate it (and
then save the new result).
• If the value is up-to-date, the reactive expression will return the
saved value without doing any computation.
69.
70. When you click “Plot y axis on the log scale”, input$log will
change and renderPlot will re-execute.
renderPlot will call dataInput()
dataInput will check that the dates and symb widgets
have not changed
dataInput will return its saved data set of stock
prices without re-fetching data from Yahoo
renderPlot will re-draw the chart with the correct axis.
71. LESSON 7
Share your apps
You will learn:
Anyone can launch your app as long as they have a copy of R,
Shiny, and a copy of your app’s files.
runUrl, runGitHub, and runGist make it simple to share and retrieve
Shiny files from web links.
You can turn your app into a live web app at its own URL
with shinyapps.io.
You can use the open source Shiny Server to build a Linux server
that hosts Shiny apps.
If you need closer control, or want to manage large volumes of
traffic, you can purchase Shiny Server Pro from RStudio.
72. When it comes to sharing Shiny apps, you have two basic options:
Share your Shiny app as two files: server.R and ui.R. This is the
simplest way to share an app, but it works only if your users have R
on their own computer (and know how to use it). Users can use
these scripts to launch the app from their own R session, just like
you’ve been launching the apps.
Share your Shiny app as a web page. This is definitely the most
user friendly way to share a Shiny app. Your users can navigate to
your app through the internet with a web browser. They will find your
app fully rendered, up to date, and ready to go.
73. Share as two R files
Anyone with R can run your Shiny app.
They will need a copy of your server.R and ui.R files, as well as any
supplementary materials used in your app (e.g., www folders
or helpers.R files).
To send your files to another user, email the files (perhaps in a zip
file) or host the files online.
Your user can place the files into an app directory in their working
directory. They can launch the app in R with the same commands
you used on your computer.
74. Shiny has three built in commands that make it easy to use files that
are hosted online: runUrl,runGitHub, and runGist.
runURL:
Save your Shiny app’s directory as a zip file
Host that zip file at its own link on a web page. Anyone with access
to the link can launch the app from inside R by running:
runGitHub
create a project repository on Github. Then store
your server.R andui.R files in the repository,
75. runGist
• Copy and paste your server.R and ui.R files to the Gist web page.
• Note the URL that Github gives the Gist.
• Once you’ve made a Gist, your users can launch the app
with runGist("<gist number>") where"<gist number>" is the number
that appears at the end of your Gist’s web address.
76. Share as a web page
All of the previous methods share the same limitation. They require
your user to have R and Shiny installed on their computer.
Shiny creates the perfect opportunity to share output with people
who do not have R
If you’d prefer an easier experience or need support, RStudio offers
three ways to host your Shiny app as a web page:
1. Shinyapps.io.
2. Shiny Server, and
3. Shiny Server Pro
77. Shinyapps.io
• lets you upload your app straight from your R session to
a server hosted by Rstudio.
Shiny Server
• Shiny Server is a companion program to Shiny that
builds a web server designed to host Shiny apps.
Shiny Server Pro
• Shiny Server will get your app to the web and take care
of all of your Shiny publishing needs