├── .gitignore
├── Classes_and_Methods
├── Classes_and_Methods.Rmd
├── Classes_and_Methods.html
├── Classes_and_Methods.pdf
├── unnamed-chunk-12.png
├── unnamed-chunk-13.png
└── unnamed-chunk-17.png
├── README.md
├── RPackages
├── example.R
├── rpackages.Rmd
├── rpackages.html
└── rpackages.pdf
├── R_Markdown
├── R_Markdown.Rmd
├── R_Markdown.html
└── R_Markdown.pdf
├── Shiny_Gadgets
├── Shiny_Gadgets.Rmd
├── Shiny_Gadgets.html
├── Shiny_Gadgets.pdf
├── multiplyNumbers.png
├── myFirstGadget.png
└── pickTrees.png
├── Shiny_Part_1
├── Shiny_Part_1.Rmd
├── Shiny_Part_1.html
├── Shiny_Part_1.pdf
├── app1.png
├── app1
│ ├── server.R
│ └── ui.R
├── app2.png
├── app2
│ ├── server.R
│ └── ui.R
├── app3.png
├── app3
│ ├── server.R
│ └── ui.R
├── app4.png
└── app4
│ ├── server.R
│ └── ui.R
├── Shiny_Part_2
├── Shiny_Part_2.Rmd
├── Shiny_Part_2.html
├── Shiny_Part_2.pdf
├── app1.png
├── app1
│ ├── server.R
│ └── ui.R
├── app2.png
├── app2
│ ├── server.R
│ └── ui.R
├── app3.png
├── app3
│ ├── server.R
│ └── ui.R
├── app4.png
└── app4
│ ├── server.R
│ └── ui.R
├── bloomberg_shield.png
├── book.Rmd
├── book.html
├── book.pdf
├── book.png
├── build.R
├── community.Rmd
├── community.html
├── community.pdf
├── googleVis
├── configoptions.png
├── googleVis.Rmd
├── googleVis.html
├── googleVis.pdf
├── googleVis_cache
│ ├── beamer
│ │ ├── __packages
│ │ ├── gv_9dbf4e117f315a77fe16b769e9c0f6b2.RData
│ │ ├── gv_9dbf4e117f315a77fe16b769e9c0f6b2.rdb
│ │ ├── gv_9dbf4e117f315a77fe16b769e9c0f6b2.rdx
│ │ ├── linechart_6d9407505251a3dc7b7c5bc643d95ef2.RData
│ │ ├── linechart_6d9407505251a3dc7b7c5bc643d95ef2.rdb
│ │ ├── linechart_6d9407505251a3dc7b7c5bc643d95ef2.rdx
│ │ ├── multiplot_81494356bc1144eef8caa488a7bb2a92.RData
│ │ ├── multiplot_81494356bc1144eef8caa488a7bb2a92.rdb
│ │ ├── multiplot_81494356bc1144eef8caa488a7bb2a92.rdx
│ │ ├── unnamed-chunk-1_b7ded69b4296a4724bf3375d4ab84970.RData
│ │ ├── unnamed-chunk-1_b7ded69b4296a4724bf3375d4ab84970.rdb
│ │ ├── unnamed-chunk-1_b7ded69b4296a4724bf3375d4ab84970.rdx
│ │ ├── unnamed-chunk-2_efae6bac495a80e9785c5fb8f683e7f3.RData
│ │ ├── unnamed-chunk-2_efae6bac495a80e9785c5fb8f683e7f3.rdb
│ │ ├── unnamed-chunk-2_efae6bac495a80e9785c5fb8f683e7f3.rdx
│ │ ├── unnamed-chunk-3_7713fa4fbd9d096e5db651140534175f.RData
│ │ ├── unnamed-chunk-3_7713fa4fbd9d096e5db651140534175f.rdb
│ │ ├── unnamed-chunk-3_7713fa4fbd9d096e5db651140534175f.rdx
│ │ ├── unnamed-chunk-4_a03d382b0ff99902a3292da4c4a82599.RData
│ │ ├── unnamed-chunk-4_a03d382b0ff99902a3292da4c4a82599.rdb
│ │ ├── unnamed-chunk-4_a03d382b0ff99902a3292da4c4a82599.rdx
│ │ ├── unnamed-chunk-5_ad9f43e8c2a360e1874f7dacbb669bb0.RData
│ │ ├── unnamed-chunk-5_ad9f43e8c2a360e1874f7dacbb669bb0.rdb
│ │ └── unnamed-chunk-5_ad9f43e8c2a360e1874f7dacbb669bb0.rdx
│ ├── html
│ │ ├── __packages
│ │ ├── gv_0a8fdc426d8671280678fb7168963fe4.RData
│ │ ├── gv_0a8fdc426d8671280678fb7168963fe4.rdb
│ │ ├── gv_0a8fdc426d8671280678fb7168963fe4.rdx
│ │ ├── linechart_569775eca9978142a8076e308950de12.RData
│ │ ├── linechart_569775eca9978142a8076e308950de12.rdb
│ │ ├── linechart_569775eca9978142a8076e308950de12.rdx
│ │ ├── multiplot_d5d31575388fbf6e6e4344cb9a4bfb05.RData
│ │ ├── multiplot_d5d31575388fbf6e6e4344cb9a4bfb05.rdb
│ │ ├── multiplot_d5d31575388fbf6e6e4344cb9a4bfb05.rdx
│ │ ├── unnamed-chunk-1_2151b3fddc27c781204361ae4cb7006f.RData
│ │ ├── unnamed-chunk-1_2151b3fddc27c781204361ae4cb7006f.rdb
│ │ ├── unnamed-chunk-1_2151b3fddc27c781204361ae4cb7006f.rdx
│ │ ├── unnamed-chunk-2_8c5f47573f056c33ee195a276fe79ccf.RData
│ │ ├── unnamed-chunk-2_8c5f47573f056c33ee195a276fe79ccf.rdb
│ │ ├── unnamed-chunk-2_8c5f47573f056c33ee195a276fe79ccf.rdx
│ │ ├── unnamed-chunk-3_32f836fbc28a7813a13da4bc6ef117cf.RData
│ │ ├── unnamed-chunk-3_32f836fbc28a7813a13da4bc6ef117cf.rdb
│ │ ├── unnamed-chunk-3_32f836fbc28a7813a13da4bc6ef117cf.rdx
│ │ ├── unnamed-chunk-4_1b442c01a204760130458afb0764aa97.RData
│ │ ├── unnamed-chunk-4_1b442c01a204760130458afb0764aa97.rdb
│ │ ├── unnamed-chunk-4_1b442c01a204760130458afb0764aa97.rdx
│ │ ├── unnamed-chunk-5_d22b6d2206374fee4b1232cafb9ca68c.RData
│ │ ├── unnamed-chunk-5_d22b6d2206374fee4b1232cafb9ca68c.rdb
│ │ └── unnamed-chunk-5_d22b6d2206374fee4b1232cafb9ca68c.rdx
│ └── latex
│ │ ├── __packages
│ │ ├── gv_f1b84de98bbecb16e7a2e7c32e1e3331.RData
│ │ ├── gv_f1b84de98bbecb16e7a2e7c32e1e3331.rdb
│ │ ├── gv_f1b84de98bbecb16e7a2e7c32e1e3331.rdx
│ │ ├── linechart_a9bf7d9448de24ede1ed7a3a532ebd7f.RData
│ │ ├── linechart_a9bf7d9448de24ede1ed7a3a532ebd7f.rdb
│ │ ├── linechart_a9bf7d9448de24ede1ed7a3a532ebd7f.rdx
│ │ ├── multiplot_47c2d2feef376bcebba06211e93e2cb6.RData
│ │ ├── multiplot_47c2d2feef376bcebba06211e93e2cb6.rdb
│ │ ├── multiplot_47c2d2feef376bcebba06211e93e2cb6.rdx
│ │ ├── unnamed-chunk-1_b00967b2f56f36d4c63de3d0550d6595.RData
│ │ ├── unnamed-chunk-1_b00967b2f56f36d4c63de3d0550d6595.rdb
│ │ ├── unnamed-chunk-1_b00967b2f56f36d4c63de3d0550d6595.rdx
│ │ ├── unnamed-chunk-2_83bd0699e86a757bca393975321fa2ce.RData
│ │ ├── unnamed-chunk-2_83bd0699e86a757bca393975321fa2ce.rdb
│ │ ├── unnamed-chunk-2_83bd0699e86a757bca393975321fa2ce.rdx
│ │ ├── unnamed-chunk-3_af5165f1511c3967e4e94eb08dd7af05.RData
│ │ ├── unnamed-chunk-3_af5165f1511c3967e4e94eb08dd7af05.rdb
│ │ ├── unnamed-chunk-3_af5165f1511c3967e4e94eb08dd7af05.rdx
│ │ ├── unnamed-chunk-4_82eb54c46b490101dad623ca487b52b9.RData
│ │ ├── unnamed-chunk-4_82eb54c46b490101dad623ca487b52b9.rdb
│ │ ├── unnamed-chunk-4_82eb54c46b490101dad623ca487b52b9.rdx
│ │ ├── unnamed-chunk-5_21ff6d18310a5d2c21111b0a5cd09469.RData
│ │ ├── unnamed-chunk-5_21ff6d18310a5d2c21111b0a5cd09469.rdb
│ │ └── unnamed-chunk-5_21ff6d18310a5d2c21111b0a5cd09469.rdx
├── googlecharts.png
└── myfilename.html
├── index.Rmd
├── index.html
├── index.pdf
├── leaflet
├── leaflet.Rmd
├── leaflet.html
└── leaflet.pdf
├── plotly
├── plotly.Rmd
├── plotly.html
└── plotly.pdf
├── sharingrmd.Rmd
├── sharingrmd.html
├── sharingrmd.pdf
├── shiny.Rmd
├── shiny.html
├── shiny.pdf
├── shinyproject.Rmd
├── shinyproject.html
├── shinyproject.pdf
├── slides.css
├── swirl
├── swirl.Rmd
├── swirl.html
└── swirl.pdf
├── syllabus.Rmd
├── syllabus.html
├── syllabus.pdf
├── welcome.Rmd
├── welcome.html
└── welcome.pdf
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .Rhistory
3 |
--------------------------------------------------------------------------------
/Classes_and_Methods/Classes_and_Methods.Rmd:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Classes and Methods in R"
3 | author: "The Johns Hopkins Data Science Lab"
4 | output: pdf_document
5 | always_allow_html: yes
6 | ---
7 |
8 | ## Classes and Methods
9 |
10 | - A system for doing object oriented programming
11 | - R was originally quite interesting because it is both interactive _and_ has a system for object orientation.
12 | - Other languages which support OOP (C++, Java, Lisp, Python, Perl) generally speaking are not interactive languages
13 |
14 | ## Classes and Methods
15 |
16 | - In R much of the code for supporting classes/methods is written by John Chambers himself (the creator of the original S language) and documented in the book _Programming with Data: A Guide to the S Language_
17 | - A natural extension of Chambers' idea of allowing someone to cross the user -> programmer spectrum
18 | - Object oriented programming is a bit different in R than it is in most languages - even if you are familiar with the idea, you may want to pay attention to the details
19 |
20 | ## Two styles of classes and methods
21 |
22 | S3 classes/methods
23 | - Included with version 3 of the S language.
24 | - Informal, a little kludgey
25 | - Sometimes called _old-style_ classes/methods
26 |
27 | S4 classes/methods
28 | - more formal and rigorous
29 | - Included with S-PLUS 6 and R 1.4.0 (December 2001)
30 | - Also called _new-style_ classes/methods
31 |
32 | ## Two worlds living side by side
33 |
34 | - For now (and the forseeable future), S3 classes/methods and S4 classes/methods are separate systems (but they can be mixed to some degree).
35 | - Each system can be used fairly independently of the other.
36 | - Developers of new projects (you!) are encouraged to use the S4 style classes/methods.
37 | - Used extensively in the Bioconductor project
38 | - But many developers still use S3 classes/methods because they are "quick and dirty" (and easier).
39 | - In this lecture we will focus primarily on S4 classes/methods
40 | - The code for implementing S4 classes/methods in R is in the *methods* package, which is usually loaded by default (but you can load it with `library(methods)` if for some reason it is not loaded)
41 |
42 | ## Object Oriented Programming in R
43 |
44 | - A class is a description of a thing. A class can be defined using `setClass()` in the *methods* package.
45 | - An _object_ is an instance of a class. Objects can be created using `new()`.
46 | - A _method_ is a function that only operates on a certain class of objects.
47 | - A generic function is an R function which dispatches methods. A generic function typically encapsulates a "generic" concept (e.g. `plot`, `mean`, `predict`, ...)
48 | - The generic function does not actually do any computation.
49 | - A _method_ is the implementation of a generic function for an object of a particular class.
50 |
51 | ## Things to look up
52 |
53 | - The help files for the 'methods' package are extensive - do read them as they are the primary documentation
54 | - You may want to start with `?Classes` and `?Methods`
55 | - Check out `?setClass`, `?setMethod`, and `?setGeneric`
56 | - Some of it gets technical, but try your best for now-it will make sense in the future as you keep using it.
57 | - Most of the documentation in the *methods* package is oriented towards developers/programmers as these are the primary people using classes/methods
58 |
59 | ## Classes
60 |
61 | All objects in R have a class which can be determined by the class function
62 |
63 | ```{r}
64 | class(1)
65 | class(TRUE)
66 | ```
67 |
68 | ## Classes
69 |
70 | ```{r}
71 | class(rnorm(100))
72 | class(NA)
73 | class("foo")
74 | ```
75 |
76 | ## Classes (cont'd)
77 |
78 | Data classes go beyond the atomic classes
79 |
80 | ```{r}
81 | x <- rnorm(100)
82 | y <- x + rnorm(100)
83 | fit <- lm(y ~ x) ## linear regression model
84 | class(fit)
85 | ```
86 |
87 | ## Generics/Methods in R
88 |
89 | - S4 and S3 style generic functions look different but conceptually, they are the same (they play the same role).
90 | - When you program you can write new methods for an existing generic OR create your own generics and associated methods.
91 | - Of course, if a data type does not exist in R that matches your needs, you can always define a new class along with generics/methods that go with it.
92 |
93 | ## An S3 generic function (in the 'base' package)
94 |
95 | The `mean` and `print` functions are generic
96 | ```{r}
97 | mean
98 | ```
99 |
100 | ## An S3 generic function (in the 'base' package)
101 |
102 | ```{r}
103 | print
104 | ```
105 |
106 | ## S3 methods
107 |
108 | The `mean` generic function has a number of methods associated with it.
109 |
110 | ```{r}
111 | methods("mean")
112 | ```
113 |
114 | ## An S4 generic function
115 |
116 | The `show` function is from the methods package and is the S4
117 | equivalent of `print`
118 | ```{r}
119 | library(methods)
120 | show
121 | ```
122 | The `show` function is usually not called directly (much like `print`)
123 | because objects are auto-printed.
124 |
125 | ## S4 methods
126 |
127 | ```{r}
128 | showMethods("show")
129 | ```
130 |
131 | ## Generic/method mechanism
132 |
133 | The first argument of a generic function is an object of a particular class (there may be other arguments)
134 |
135 | 1. The generic function checks the class of the object.
136 | 2. A search is done to see if there is an appropriate method for that class.
137 | 3. If there exists a method for that class, then that method is called on the object and we're done.
138 | 4. If a method for that class does not exist, a search is done to see if there is a default method for the generic. If a default exists, then the default method is called.
139 | 5. If a default method doesn't exist, then an error is thrown.
140 |
141 | ## Examining Code for Methods
142 |
143 | - You cannot just print the code for a method like other functions because the code for the method is usually hidden.
144 | - If you want to see the code for an S3 method, you can use the function `getS3method`.
145 | - The call is `getS3method(, )`
146 | - For S4 methods you can use the function `getMethod`
147 | - The call is `getMethod(, )` (more details later)
148 |
149 | ## S3 Class/Method: Example 1
150 |
151 | What's happening here?
152 |
153 | ```{r}
154 | set.seed(2)
155 | x <- rnorm(100)
156 | mean(x)
157 | ```
158 |
159 | 1. The class of x is "numeric"
160 | 2. But there is no mean method for "numeric" objects!
161 | 3. So we call the default function for `mean`.
162 |
163 | ## S3 Class/Method: Example 1
164 |
165 | ```{r}
166 | head(getS3method("mean", "default"), 10)
167 | ```
168 |
169 | ## S3 Class/Method: Example 1
170 |
171 | ```{r}
172 | tail(getS3method("mean", "default"), 10)
173 | ```
174 |
175 | ## S3 Class/Method: Example 2
176 |
177 | What happens here?
178 |
179 | ```{r}
180 | set.seed(3)
181 | df <- data.frame(x = rnorm(100), y = 1:100)
182 | sapply(df, mean)
183 | ```
184 |
185 | ## S3 Class/Method: Example 2
186 |
187 | 1. The class of `df` is "data.frame"; each column can be an object of
188 | a different class
189 |
190 | 2. We `sapply` over the columns and call the `mean` function
191 |
192 | 3. In each column, `mean` checks the class of the object and dispatches the
193 | appropriate method.
194 |
195 | 4. We have a `numeric` column and an `integer` column; `mean` calls the default method for both
196 |
197 | ## Calling Methods Directly
198 |
199 | * Some S3 methods are visible to the user (i.e. `mean.default`),
200 |
201 | * Never call methods directly
202 |
203 | * Use the generic function and let the method be dispatched
204 | automatically.
205 |
206 | * With S4 methods you cannot call them directly at all
207 |
208 | ## S3 Class/Method: Example 3
209 |
210 | The `plot` function is generic and its behavior depends on the object being plotted.
211 |
212 | ```{r ex3_1,eval=FALSE}
213 | set.seed(10)
214 | x <- rnorm(100)
215 | plot(x)
216 | ```
217 |
218 | ## S3 Class/Method: Example 3
219 |
220 | ```{r tenPlot, echo=FALSE}
221 | set.seed(10)
222 | x <- rnorm(100)
223 | plot(x)
224 | ```
225 |
226 | ## S3 Class/Method: Example 3
227 |
228 | For time series objects, `plot` connects the dots
229 |
230 | ```{r ex3_3,eval=FALSE}
231 | set.seed(10)
232 | x <- rnorm(100)
233 | x <- as.ts(x) ## Convert to a time series object
234 | plot(x)
235 | ```
236 |
237 | ## S3 Class/Method: Example 3
238 |
239 | ```{r ex3_4,echo=FALSE}
240 | set.seed(10)
241 | x <- rnorm(100)
242 | x <- as.ts(x) ## Convert to a time series object
243 | plot(x)
244 | ```
245 |
246 | ## Write your own methods!
247 |
248 | If you write new methods for new classes, you'll probably end up writing methods for the following generics:
249 | - print/show
250 | - summary
251 | - plot
252 |
253 | There are two ways that you can extend the R system via classes/methods
254 | - Write a method for a new class but for an existing generic function (i.e. like
255 | `print`)
256 | - Write new generic functions and new methods for those generics
257 |
258 | ## S4 Classes
259 |
260 | Why would you want to create a new class?
261 | - To represent new types of data (e.g. gene expression, space-time, hierarchical, sparse matrices)
262 | - New concepts/ideas that haven't been thought of yet (e.g. a fitted point process model, mixed-effects model, a sparse matrix)
263 | - To abstract/hide implementation details from the user
264 | I say things are "new" meaning that R does not know about them (not that they are new to the statistical community).
265 |
266 | ## S4 Class/Method: Creating a New Class
267 |
268 | A new class can be defined using the `setClass` function
269 | - At a minimum you need to specify the name of the class
270 | - You can also specify data elements that are called _slots_
271 | - You can then define methods for the class with the `setMethod` function
272 | - Information about a class definition can be obtained with the `showClass` function
273 |
274 | ## S4 Class/Method: Polygon Class
275 |
276 | Creating new classes/methods is usually not something done at the console; you likely want to save the code in a separate file
277 |
278 | ```{r polygon_1, tidy = FALSE}
279 | library(methods)
280 | setClass("polygon",
281 | representation(x = "numeric",
282 | y = "numeric"))
283 | ```
284 |
285 | - The slots for this class are `x` and `y`
286 |
287 | - The slots for an S4 object can be accessed with the `@` operator.
288 |
289 | ## S4 Class/Method: Polygon Class
290 |
291 | A plot method can be created with the `setMethod` function.
292 |
293 | - For `setMethod` you need to specify a generic function (`plot`), and
294 | a _signature_.
295 |
296 | - A signature is a character vector indicating the classes of objects
297 | that are accepted by the method.
298 |
299 | - In this case, the `plot` method will take one type of object, a
300 | `polygon` object.
301 |
302 | ## S4 Class/Method: Polygon Class
303 |
304 | Creating a `plot` method with `setMethod`.
305 |
306 | ```{r polygon_2, tidy = FALSE}
307 | setMethod("plot", "polygon",
308 | function(x, y, ...) {
309 | plot(x@x, x@y, type = "n", ...)
310 | xp <- c(x@x, x@x[1])
311 | yp <- c(x@y, x@y[1])
312 | lines(xp, yp)
313 | })
314 | ```
315 |
316 | - Notice that the slots of the polygon (the x- and y-coordinates) are
317 | accessed with the `@` operator.
318 |
319 | ## S4 Class/Method: Polygon Class
320 |
321 | After calling `setMethod` the new `plot` method will be added to the list of methods for `plot`.
322 |
323 | ```{r polygon_3}
324 | library(methods)
325 | showMethods("plot")
326 | ```
327 |
328 | Notice that the signature for class `polygon` is listed. The method for `ANY` is the default method and it is what is called when now other signature matches
329 |
330 | ## S4 Class/Method: Polygon class
331 |
332 | ```{r polygon_4}
333 | p <- new("polygon", x = c(1, 2, 3, 4), y = c(1, 2, 3, 1))
334 | plot(p)
335 | ```
336 |
337 | ## Summary
338 |
339 | - Developing classes and associated methods is a powerful way to
340 | extend the functionality of R
341 |
342 | - Classes define new data types
343 |
344 | - Methods extend generic functions to specify the behavior
345 | of generic functions on new classes
346 |
347 | - As new data types and concepts are created, classes/methods provide
348 | a way for you to develop an intuitive interface to those
349 | data/concepts for users
350 |
351 | ## Where to Look, Places to Start
352 |
353 | - The best way to learn this stuff is to look at examples
354 |
355 | - There are quite a few examples on CRAN which use S4
356 | classes/methods. You can usually tell if they use S4 classes/methods
357 | if the methods package is listed in the `Depends:` field
358 |
359 | - Bioconductor (http://www.bioconductor.org) - a rich resource, even
360 | if you know nothing about bioinformatics
361 |
362 | - Some packages on CRAN (as far as I know) - SparseM, gpclib, flexmix,
363 | its, lme4, orientlib, filehash
364 |
365 | - The `stats4` package (comes with R) has a bunch of classes/methods
366 | for doing maximum likelihood analysis.
367 |
368 |
--------------------------------------------------------------------------------
/Classes_and_Methods/Classes_and_Methods.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/Classes_and_Methods/Classes_and_Methods.pdf
--------------------------------------------------------------------------------
/Classes_and_Methods/unnamed-chunk-12.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/Classes_and_Methods/unnamed-chunk-12.png
--------------------------------------------------------------------------------
/Classes_and_Methods/unnamed-chunk-13.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/Classes_and_Methods/unnamed-chunk-13.png
--------------------------------------------------------------------------------
/Classes_and_Methods/unnamed-chunk-17.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/Classes_and_Methods/unnamed-chunk-17.png
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Developing Data Products
2 |
3 | Developing Data Products Course from the Johns Hopkins Data Science Lab
4 |
5 | Course Site: http://datasciencespecialization.github.io/Developing_Data_Products
6 |
7 | ### Contributors
8 |
9 | * Brian Caffo
10 | * Jeff Leek
11 | * Roger Peng
12 | * Sean Kross
13 |
14 | ### License
15 |
16 | 
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
17 |
18 | ### Building this Site
19 |
20 | 1. `cd` to this repository.
21 | 2. `Rscript build.R`
22 |
23 | `Rscript build.R clean` to start from scratch.
--------------------------------------------------------------------------------
/RPackages/example.R:
--------------------------------------------------------------------------------
1 | #' Building a Model with Top Ten Features
2 | #'
3 | #' This function develops a prediction algorithm based on the top 10 features
4 | #' in 'x' that are most predictive of 'y'.
5 | #'
6 | #' @param x a n x p matrix of n observations and p predictors
7 | #' @param y a vector of length n representing the response
8 | #' @return a 'lm' object representing the linear model with the top 10 predictors
9 | #' @author Roger Peng
10 | #' @details
11 | #' This function runs a univariate regression of y on each predictor in x and
12 | #' calculates the p-value indicating the significance of the association. The
13 | #' final set of 10 predictors is the taken from the 10 smallest p-values.
14 | #' @seealso \code{lm}
15 | #' @import stats
16 | #' @export
17 |
18 | topten <- function(x, y) {
19 | p <- ncol(x)
20 | if(p < 10)
21 | stop("there are less than 10 predictors")
22 | pvalues <- numeric(p)
23 | for(i in seq_len(p)) {
24 | fit <- lm(y ~ x[, i])
25 | summ <- summary(fit)
26 | pvalues[i] <- summ$coefficients[2, 4]
27 | }
28 | ord <- order(pvalues)
29 | x10 <- x[, ord]
30 | fit <- lm(y ~ x10)
31 | coef(fit)
32 | }
33 |
34 | #' Prediction with Top Ten Features
35 | #'
36 | #' This function takes a set coefficients produced by the \code{topten}
37 | #' function and makes a prediction for each of the values provided in the
38 | #' input 'X' matrix.
39 | #'
40 | #' @param X a n x 10 matrix containing n observations
41 | #' @param b a vector of coefficients obtained from the \code{topten} function
42 | #' @return a numeric vector containing the predicted values
43 |
44 | predict10 <- function(X, b) {
45 | X <- cbind(1, X)
46 | drop(X %*% b)
47 | }
48 |
--------------------------------------------------------------------------------
/RPackages/rpackages.Rmd:
--------------------------------------------------------------------------------
1 | ---
2 | title : Building R Packages
3 | author : Roger D. Peng, Professor of Biostatistics
4 | output:
5 | ioslides_presentation:
6 | logo: ../../img/bloomberg_shield.png
7 | beamer_presentation: default
8 | always_allow_html: yes
9 | ---
10 |
11 | ## What is an R Package?
12 |
13 | - A mechanism for extending the basic functionality of R
14 | - A collection of R functions, or other (data) objects
15 | - Organized in a systematic fashion to provide a minimal amount of consistency
16 | - Written by users/developers everywhere
17 |
18 |
19 |
20 | ## Where are These R Packages?
21 |
22 | - Primarily available from CRAN and Bioconductor
23 |
24 | - Also available from GitHub, Bitbucket, Gitorious, etc. (and elsewhere)
25 |
26 | - Packages from CRAN/Bioconductor can be installed with `install.packages()`
27 |
28 | - Packages from GitHub can be installed using `install_github()` from
29 | the devtools package
30 |
31 | You do not have to put a package on a central repository, but doing so
32 | makes it easier for others to install your package.
33 |
34 |
35 |
36 | ## What's the Point?
37 |
38 | - "Why not just make some code available?"
39 | - Documentation / vignettes
40 | - Centralized resources like CRAN
41 | - Minimal standards for reliability and robustness
42 | - Maintainability / extension
43 | - Interface definition / clear API
44 | - Users know that it will at least load properly
45 |
46 |
47 |
48 | ## Package Development Process
49 |
50 | - Write some code in an R script file (.R)
51 | - Want to make code available to others
52 | - Incorporate R script file into R package structure
53 | - Write documentation for user functions
54 | - Include some other material (examples, demos, datasets, tutorials)
55 | - Package it up!
56 |
57 |
58 |
59 | ## Package Development Process
60 |
61 | - Submit package to CRAN or Bioconductor
62 | - Push source code repository to GitHub or other source code sharing web site
63 | - People find all kinds of problems with your code
64 | - Scenario #1: They tell you about those problems and expect you to fix it
65 | - Scenario #2: They fix the problem for you and show you the changes
66 | - You incorporate the changes and release a new version
67 |
68 |
69 |
70 | ## R Package Essentials
71 |
72 | - An R package is started by creating a directory with the name of the R package
73 | - A DESCRIPTION file which has info about the package
74 | - R code! (in the R/ sub-directory)
75 | - Documentation (in the man/ sub-directory)
76 | - NAMESPACE
77 | - Full requirements in Writing R Extensions
78 |
79 |
80 |
81 | ## The DESCRIPTION File
82 |
83 | - Package: Name of package (e.g. library(name))
84 | - Title: Full name of package
85 | - Description: Longer description of package in one sentence (usually)
86 | - Version: Version number (usually M.m-p format)
87 | - Author, Authors@R: Name of the original author(s)
88 | - Maintainer: Name + email of person who fixes problems
89 | - License: License for the source code
90 |
91 |
92 |
93 | ## The DESCRIPTION File
94 |
95 | These fields are optional but commonly used
96 |
97 | - Depends: R packages that your package depends on
98 | - Suggests: Optional R packages that users may want to have installed
99 | - Date: Release date in YYYY-MM-DD format
100 | - URL: Package home page
101 | - Other fields can be added
102 |
103 |
104 |
105 | ## DESCRIPTION File: `gpclib`
106 |
107 | Package: gpclib
108 | Title: General Polygon Clipping Library for R
109 | Description: General polygon clipping routines for R based on Alan Murta's C library.
110 | Version: 1.5-5
111 | Author: Roger D. Peng with contributions from Duncan Murdoch and Barry Rowlingson; GPC library by Alan Murta
112 | Maintainer: Roger D. Peng
113 | License: file LICENSE
114 | Depends: R (>= 2.14.0), methods
115 | Imports: graphics
116 | Date: 2013-04-01
117 | URL: http://www.cs.man.ac.uk/~toby/gpc/, http://github.com/rdpeng/gpclib
118 |
119 |
120 |
121 | ## R Code
122 |
123 | - Copy R code into the R/ sub-directory
124 | - There can be any number of files in this directory
125 | - Usually separate out files into logical groups
126 | - Code for all functions should be included here and not anywhere else in the package
127 |
128 |
129 |
130 | ## The NAMESPACE File
131 |
132 | - Used to indicate which functions are exported
133 | - Exported functions can be called by the user and are considered the public API
134 | - Non-exported functions cannot be called directly by the user (but the code can be viewed)
135 | - Hides implementation details from users and makes a cleaner package interface
136 |
137 |
138 |
139 | ## The NAMESPACE File
140 |
141 | - You can also indicate what functions you import from other packages
142 | - This allows for your package to use other packages without making other packages visible to the user
143 | - Importing a function loads the package but does not attach it to the search list
144 |
145 |
146 |
147 | ## The NAMESPACE File
148 |
149 | Key directives
150 |
151 | - export("\")
152 | - import("\")
153 | - importFrom("\", "\")
154 |
155 | Also important
156 |
157 | - exportClasses("\")
158 | - exportMethods("\")
159 |
160 |
161 |
162 | ## NAMESPACE File: `mvtsplot` package
163 |
164 | ```r
165 | export("mvtsplot")
166 | import(splines)
167 | import(RColorBrewer)
168 | importFrom("grDevices", "colorRampPalette", "gray")
169 | importFrom("graphics", "abline", "axis", "box", "image",
170 | "layout", "lines", "par", "plot", "points",
171 | "segments", "strwidth", "text", "Axis")
172 | importFrom("stats", "complete.cases", "lm", "na.exclude",
173 | "predict", "quantile")
174 | ```
175 |
176 |
177 |
178 | ## NAMESPACE File: `gpclib` package
179 |
180 | ```r
181 | export("read.polyfile", "write.polyfile")
182 |
183 | importFrom(graphics, plot)
184 |
185 | exportClasses("gpc.poly", "gpc.poly.nohole")
186 |
187 | exportMethods("show", "get.bbox", "plot", "intersect", "union",
188 | "setdiff", "[", "append.poly", "scale.poly",
189 | "area.poly", "get.pts", "coerce", "tristrip",
190 | "triangulate")
191 | ```
192 |
193 |
194 |
195 | ## Documentation
196 |
197 | - Documentation files (.Rd) placed in man/ sub-directory
198 | - Written in a specific markup language
199 | - Required for every exported function
200 | - Another reason to limit exported functions
201 | - You can document other things like concepts, package overview
202 |
203 |
204 |
205 | ## Help File Example: `line` Function
206 |
207 | ```
208 | \name{line}
209 | \alias{line}
210 | \alias{residuals.tukeyline}
211 | \title{Robust Line Fitting}
212 | \description{
213 | Fit a line robustly as recommended in \emph{Exploratory Data Analysis}.
214 | }
215 | ```
216 |
217 |
218 |
219 | ## Help File Example: `line` Function
220 |
221 | ```
222 | \usage{
223 | line(x, y)
224 | }
225 | \arguments{
226 | \item{x, y}{the arguments can be any way of specifying x-y pairs. See
227 | \code{\link{xy.coords}}.}
228 | }
229 | ```
230 |
231 |
232 |
233 | ## Help File Example: `line` Function
234 |
235 | ```
236 | \details{
237 | Cases with missing values are omitted.
238 |
239 | Long vectors are not supported.
240 | }
241 | \value{
242 | An object of class \code{"tukeyline"}.
243 |
244 | Methods are available for the generic functions \code{coef},
245 | \code{residuals}, \code{fitted}, and \code{print}.
246 | }
247 | ```
248 |
249 |
250 |
251 | ## Help File Example: `line` Function
252 |
253 | ```
254 | \references{
255 | Tukey, J. W. (1977).
256 | \emph{Exploratory Data Analysis},
257 | Reading Massachusetts: Addison-Wesley.
258 | }
259 | ```
260 |
261 |
262 |
263 | ## Building and Checking
264 |
265 | - R CMD build is a command-line program that creates a package archive
266 | file (`.tar.gz`)
267 |
268 | - R CMD check runs a battery of tests on the package
269 |
270 | - You can run R CMD build or R CMD check from the command-line using a
271 | terminal or command-shell application
272 |
273 | - You can also run them from R using the system() function
274 |
275 | ```r
276 | system("R CMD build newpackage")
277 | system("R CMD check newpackage")
278 | ```
279 |
280 |
281 |
282 | ## Checking
283 |
284 | - R CMD check runs a battery tests
285 | - Documentation exists
286 | - Code can be loaded, no major coding problems or errors
287 | - Run examples in documentation
288 | - Check docs match code
289 | - All tests must pass to put package on CRAN
290 |
291 |
292 |
293 |
294 | ## Getting Started
295 |
296 | - The `package.skeleton()` function in the utils package creates a "skeleton" R package
297 | - Directory structure (R/, man/), DESCRIPTION file, NAMESPACE file, documentation files
298 | - If there are functions visible in your workspace, it writes R code files to the R/ directory
299 | - Documentation stubs are created in man/
300 | - You need to fill in the rest!
301 |
302 |
303 |
304 | ## Summary
305 |
306 | - R packages provide a systematic way to make R code available to others
307 | - Standards ensure that packages have a minimal amount of documentation and robustness
308 | - Obtained from CRAN, Bioconductor, Github, etc.
309 |
310 |
311 |
312 | ## Summary
313 |
314 | - Create a new directory with R/ and man/ sub-directories (or just use package.skeleton())
315 | - Write a DESCRIPTION file
316 | - Copy R code into the R/ sub-directory
317 | - Write documentation files in man/ sub-directory
318 | - Write a NAMESPACE file with exports/imports
319 | - Build and check
320 |
321 |
--------------------------------------------------------------------------------
/RPackages/rpackages.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/RPackages/rpackages.pdf
--------------------------------------------------------------------------------
/R_Markdown/R_Markdown.Rmd:
--------------------------------------------------------------------------------
1 | ---
2 | title: "R Markdown"
3 | author: "The Johns Hopkins Data Science Lab"
4 | output:
5 | beamer_presentation: default
6 | ioslides_presentation:
7 | logo: ../../img/bloomberg_shield.png
8 | slidy_presentation: default
9 | always_allow_html: yes
10 | ---
11 |
12 | ## Introduction
13 |
14 | R Markdown is built into RStudio and allows you to create documents like HTML, PDF, and Word documents from R. With R Markdown, you can embed R code into your documents.
15 |
16 | ### Why use R Markdown?
17 | - Turn work in R into more accessible formats
18 | - Incorporate R code and R plots into documents
19 | - R Markdown documents are reproducible -- the source code gets rerun every time a document is generated, so if data change or source code changes, the output in the document will change with it.
20 |
21 | ## Getting Started
22 |
23 | - Create a new R Markdown file in RStudio by going to
24 | File > New File > R Markdown...
25 | - Click the "presentation" tab
26 | - Enter a title, author, and select what kind of slideshow you ultimately want (this can all be changed later)
27 |
28 | ## Getting Started
29 | The beginning of an R Markdown file looks like this:
30 | `---`
31 | `title: "Air Quality"`
32 | `author: "JHU"`
33 | `date: "May 17, 2016"`
34 | `output: html_document`
35 | `---`
36 | The new document you've created will contain example text and code below this -- delete it for a fresh start.
37 |
38 | ## Making Your First Slide
39 | - Title your first slide using two # signs:
`## Insert Title Here`
40 | - To make a slide without a title, use three asterisks:
`***`
41 | - You can add subheadings with more # signs:
42 | `### Subheading` or `#### Smaller Subheading`
43 | - To add a new slide, just add another Title:
`## New Slide Title`
44 |
45 | ## Adding Text
46 | - Add bullet points to a slide using a hyphen followed by a space:
47 | `- bullet point`
48 | - Add sub-points using four spaces and a plus sign:
49 | `+ sub-point`
50 | - Add an ordered list by typing the number/letter:
51 | `1. first point`
52 | `a) sub-sub-point`
53 | - Add bullet points that appear one by one (on click) with:
54 | `>- iterated bullet point`
55 |
56 | ## Formatting Text
57 | Text Code in R Markdown
58 | ---------------------------------- ----------------------------------------
59 | plain text `plain text`
60 | *italics* `*italics*`
61 | **bold** `**bold**`
62 | [link](http://www.jhsph.edu) `[link](http://www.jhsph.edu)`
63 | `verbatim code` ` `code here` `
64 |
65 | ## Embedding R Code
66 | This is a chunk of R code in R Markdown:
67 | \`\`\`{r}
68 | `head(airquality)`
69 | \`\`\`
70 | The code gets run, and both the input and output are displayed.
71 | ```{r}
72 | head(airquality)
73 | ```
74 |
75 | ## Embedding R Code
76 | To hide the input code, use `echo=FALSE`.
77 | \`\`\`{r, echo=FALSE}
78 | `head(airquality)`
79 | \`\`\`
80 | ```{r, echo=FALSE}
81 | head(airquality)
82 | ```
83 | This can be useful for showing plots.
84 |
85 | ## Embedding R Code
86 | To show the input code only, use `eval=FALSE`.
87 | \`\`\`{r, eval=FALSE}
88 | `head(airquality)`
89 | \`\`\`
90 | ```{r, eval=FALSE}
91 | head(airquality)
92 | ```
93 |
94 | ## Embedding R Code
95 | To run the code without showing input or output, use `include=FALSE`.
96 | \`\`\`{r, include=FALSE}
97 | `library(ggplot2)`
98 | \`\`\`
99 |
100 | ## Generating Slideshows
101 | - Click the **Knit** button at the top of the R Markdown document to generate your new document.
102 | + You may be asked to install required packages if you don't already have them installed -- hit "Yes" and RStudio will install them for you
103 | - You can change the type of document generated by changing the `output` line in the header, or by selecting an output from the **Knit** button's pull-down menu.
104 |
105 | ## Generating Slideshows
106 | - HTML: two options with different looks
107 | + `output: ioslides_presentation`
108 | + `output: slidy_presentation`
109 | - PDF: `output: beamer_presentation`
110 | - Note: You can specify multiple outputs at the beginning of the R Markdown file if you will need to generate multiple filetypes.
111 |
112 | ## PDFs and LaTeX
113 | - To **knit** a PDF slideshow, you will need to install **LaTeX** on your computer
114 | - LaTeX is a typesetting system that is needed to convert R Markdown into formatted text for PDFs
115 |
116 | ### Downloading and Installing LaTeX
117 | - *LaTeX* is free
118 | - LaTeX takes up a lot of space (almost ~2.6 GB download and takes up ~5 GB when installed)
119 | - Visit [https://www.tug.org/begin.html](https://www.tug.org/begin.html) to download LaTeX for your operating system
120 | - Depending on your internet connection, it may take a while to download due to its size
121 |
122 | ## Conclusion
123 |
124 | For more information about R Markdown visit http://rmarkdown.rstudio.com/
125 |
--------------------------------------------------------------------------------
/R_Markdown/R_Markdown.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/R_Markdown/R_Markdown.pdf
--------------------------------------------------------------------------------
/Shiny_Gadgets/Shiny_Gadgets.Rmd:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Shiny Gadgets"
3 | author: "The Johns Hopkins Data Science Lab"
4 | output:
5 | ioslides_presentation:
6 | logo: ../../img/bloomberg_shield.png
7 | beamer_presentation: default
8 | always_allow_html: yes
9 | ---
10 |
11 | ## Introduction
12 |
13 | Shiny Gadgets provide a way to use Shiny's interactivity and
14 | user interface tools as a part of a data analysis. With
15 | Shiny Gadgets you can create a function that opens a small
16 | Shiny app. Since these apps are smaller we'll be using the
17 | miniUI package for creating user interfaces.
18 |
19 | ## A Simple Gadget
20 |
21 | At its core a Shiny Gadget is a function that launches a
22 | small (single-page) Shiny application. Since Shiny Gadgets
23 | are meant to be displayed in the RStudio viewer pane, the
24 | miniUI package comes in handy for its smaller graphical
25 | elements. Let's construct a very simple Shiny Gadget.
26 |
27 | ## A Simple Gadget: Code
28 |
29 | ```r
30 | library(shiny)
31 | library(miniUI)
32 |
33 | myFirstGadget <- function() {
34 | ui <- miniPage(
35 | gadgetTitleBar("My First Gadget")
36 | )
37 | server <- function(input, output, session) {
38 | # The Done button closes the app
39 | observeEvent(input$done, {
40 | stopApp()
41 | })
42 | }
43 | runGadget(ui, server)
44 | }
45 | ```
46 |
47 | ## A Simple Gadget: Image
48 |
49 | 
50 |
51 | ## A Simple Gadget: Code Review
52 |
53 | Source the preceding code and run `myFirstGadget()` to see
54 | a very basic Shiny Gadget. Just to review some of the new
55 | functions in this Gadget:
56 |
57 | - `miniPage()` creates a small layout.
58 | - `gadgetTitleBar()` provides a title bar with Done and
59 | Cancel buttons.
60 | - `runGadget()` runs the Shiny Gadget, taking `ui` and
61 | `server` as arguments.
62 |
63 | ## Gadgets with Arguments
64 |
65 | One of the advantages of Shiny Gadgets is that since Shiny
66 | Gadgets are functions they can take values as arguments and
67 | they can return values. Let's take a look at a simple
68 | example of a Shiny Gadget that takes arguments and returns
69 | a value. The following Shiny Gadget takes two different
70 | vectors of numbers as arguments and uses those vectors to
71 | populate two `selectInput`s. The user can then choose two
72 | numbers within the Gadget, and the product of those two
73 | numbers will be returned.
74 |
75 | ## Gadgets with Arguments: Code Part 1
76 |
77 | ```r
78 | library(shiny)
79 | library(miniUI)
80 |
81 | multiplyNumbers <- function(numbers1, numbers2) {
82 | ui <- miniPage(
83 | gadgetTitleBar("Multiply Two Numbers"),
84 | miniContentPanel(
85 | selectInput("num1", "First Number", choices=numbers1),
86 | selectInput("num2", "Second Number", choices=numbers2)
87 | )
88 | )
89 | ```
90 | ## Gadgets with Arguments: Code Part 2
91 |
92 | ```r
93 | server <- function(input, output, session) {
94 | observeEvent(input$done, {
95 | num1 <- as.numeric(input$num1)
96 | num2 <- as.numeric(input$num2)
97 | stopApp(num1 * num2)
98 | })
99 | }
100 | runGadget(ui, server)
101 | }
102 | ```
103 |
104 | ## Gadgets with Arguments: Image
105 |
106 | 
107 |
108 | ## Gadgets with Arguments: Code Review
109 |
110 | Source the preceding code and run
111 | `multiplyNumbers(1:5, 6:10)` so you
112 | can get a sense of how this Gadget works. As you can see
113 | this Gadget uses `selectInput()` so that the user can
114 | select two different numbers. Clicking the Done button
115 | multiplies the tow numbers together, which is returned as
116 | the result of the `multiplyNumbers()` function.
117 |
118 | ## Gadgets with Interactive Graphics
119 |
120 | Shiny Gadgets are particularly useful when a data analysis
121 | needs a touch of human intervention. You can imagine
122 | presenting an interactive data visualization through a
123 | Gadget, where an analyst could manipulate data in the
124 | Gadget, and then the Gadget would return the manipulated
125 | data. Let's walk though an example of how this could be done.
126 |
127 | ## Gadgets with Interactive Graphics: Code Part 1
128 |
129 | ```r
130 | library(shiny)
131 | library(miniUI)
132 |
133 | pickTrees <- function() {
134 | ui <- miniPage(
135 | gadgetTitleBar("Select Points by Dragging your Mouse"),
136 | miniContentPanel(
137 | plotOutput("plot", height = "100%", brush = "brush")
138 | )
139 | )
140 | ```
141 |
142 | ## Gadgets with Interactive Graphics: Code Part 2
143 |
144 | ```r
145 | server <- function(input, output, session) {
146 | output$plot <- renderPlot({
147 | plot(trees$Girth, trees$Volume, main = "Trees!",
148 | xlab = "Girth", ylab = "Volume")
149 | })
150 | observeEvent(input$done, {
151 | stopApp(brushedPoints(trees, input$brush,
152 | xvar = "Girth", yvar = "Volume"))
153 | })
154 | }
155 |
156 | runGadget(ui, server)
157 | }
158 | ```
159 |
160 | ## Gadgets with Interactive Graphics: Image
161 |
162 | 
163 |
164 | ## Gadgets with Interactive Graphics: Code Review
165 |
166 | Source the preceding code and run `pickTrees()`. Click and
167 | drag a box over the graph. Once you've drawn a box that
168 | you're satisfied with click the Done button and the points
169 | that you selected will be returned to you as a data frame.
170 | This functionality is made possible by the `brushedPoints()`
171 | function, which is part of the `shiny` package. (See
172 | `?shiny::brushedPoints` for more information.)
173 |
174 | ## Conclusion
175 |
176 | For more details about Shiny Gadgets visit the Shiny Gadgets
177 | website:
178 |
179 | - http://shiny.rstudio.com/articles/gadgets.html
180 | - http://shiny.rstudio.com/articles/gadget-ui.html
--------------------------------------------------------------------------------
/Shiny_Gadgets/Shiny_Gadgets.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/Shiny_Gadgets/Shiny_Gadgets.pdf
--------------------------------------------------------------------------------
/Shiny_Gadgets/multiplyNumbers.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/Shiny_Gadgets/multiplyNumbers.png
--------------------------------------------------------------------------------
/Shiny_Gadgets/myFirstGadget.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/Shiny_Gadgets/myFirstGadget.png
--------------------------------------------------------------------------------
/Shiny_Gadgets/pickTrees.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/Shiny_Gadgets/pickTrees.png
--------------------------------------------------------------------------------
/Shiny_Part_1/Shiny_Part_1.Rmd:
--------------------------------------------------------------------------------
1 | ---
2 | title: 'Shiny: Part 1'
3 | author: "The Johns Hopkins Data Science Lab"
4 | always_allow_html: yes
5 | ---
6 |
7 | ## What is Shiny?
8 |
9 | - Shiny is a web application framework for R.
10 | - Shiny allows you to create a graphical interface so that
11 | users can interact with your visualizations, models, and
12 | algorithms without needed to know R themselves.
13 | - Using Shiny, the time to create simple, yet powerful,
14 | web-based interactive data products in R is minimized.
15 | - Shiny is made by the fine folks at R Studio.
16 |
17 | ## Some Mild Prerequisites
18 |
19 | Shiny doesn't really require it, but as with all web
20 | programming, a little knowledge of HTML, CSS and Javascript
21 | is very helpful.
22 |
23 | - HTML gives a web page structure and sectioning as well as markup instructions
24 | - CSS gives the style
25 | - Javscript for interactivity
26 |
27 | Shiny uses [Bootstrap](http://getbootstrap.com/) (no
28 | relation to the statistics bootstrap) style, which (to me)
29 | seems to look nice and renders well on mobile platforms.
30 |
31 | ## Available Tutorials
32 |
33 | If you're interested in learning more about HTML, CSS, and
34 | Javascript we recommend any one of the following resources:
35 |
36 | - [Mozilla Developer Network Tutorials](https://developer.mozilla.org/en-US/docs/Web/Tutorials)
37 | - [HTML & CSS from Khan Academy](https://www.khanacademy.org/computing/computer-programming/html-css)
38 | - [Tutorials from Free Code Camp](https://www.freecodecamp.com/)
39 |
40 | ## Getting Started
41 |
42 | - Make sure you have the latest release of R installed
43 | - If on Windows, make sure that you have Rtools installed
44 | - `install.packages("shiny")`
45 | - `library(shiny)`
46 | - Great tutorial at http://shiny.rstudio.com/tutorial/
47 | - Basically, this lecture is walking through that tutorial
48 | offering some of our insights
49 |
50 | ## A Shiny project
51 |
52 | A shiny project is a directory containing at least two files:
53 |
54 | - `ui.R` (for user interface) controls how your app looks.
55 | - `server.R` that controls what your app does.
56 |
57 | ## ui.R
58 |
59 | ```r
60 | library(shiny)
61 | shinyUI(fluidPage(
62 | titlePanel("Data science FTW!"),
63 | sidebarLayout(
64 | sidebarPanel(
65 | h3("Sidebar Text")
66 | ),
67 | mainPanel(
68 | h3("Main Panel Text")
69 | )
70 | )
71 | ))
72 | ```
73 |
74 | ## server.R
75 |
76 | ```r
77 | library(shiny)
78 | shinyServer(function(input, output) {
79 |
80 | })
81 | ```
82 |
83 | ## To run it
84 | - In R, change to the directories with these files and type `runApp()`
85 | - or put the path to the directory as an argument
86 | - It should open a browser window with the app running
87 |
88 | ## Your First Shiny App
89 |
90 | 
91 |
92 | ## HTML Tags in Shiny
93 |
94 | Shiny provides several wrapper functions for using
95 | standard HTML tags in your `ui.R`, including `h1()` through
96 | `h6()`, `p()`, `a()`, `div()`, and `span()`.
97 |
98 | - See `?builder` for more details.
99 |
100 | ## R Wrappers for HTML Tags
101 |
102 | ```r
103 | library(shiny)
104 | shinyUI(fluidPage(
105 | titlePanel("HTML Tags"),
106 | sidebarLayout(
107 | sidebarPanel(
108 | h1("H1 Text"),
109 | h3("H3 Text"),
110 | em("Emphasized Text")
111 | ),
112 | mainPanel(
113 | h3("Main Panel Text"),
114 | code("Some Code!")
115 | )
116 | )
117 | ))
118 | ```
119 |
120 | ## App with Many Tags
121 |
122 | 
123 |
124 | ## App with Inputs and Outputs
125 |
126 | Now that you've played around with customizing the look of
127 | your app, let's give it some functionality! Shiny provides
128 | several types of inputs including buttons, checkboxes, text
129 | boxes, and calendars. First let's experiment with the slider
130 | input. This simple app will display the number that is
131 | selected with a slider.
132 |
133 | ## Slider App: ui.R
134 |
135 | ```r
136 | library(shiny)
137 | shinyUI(fluidPage(
138 | titlePanel("Slider App"),
139 | sidebarLayout(
140 | sidebarPanel(
141 | h1("Move the Slider!"),
142 | sliderInput("slider1", "Slide Me!", 0, 100, 0)
143 | ),
144 | mainPanel(
145 | h3("Slider Value:"),
146 | textOutput("text")
147 | )
148 | )
149 | ))
150 | ```
151 |
152 | ## Slider App: server.R
153 |
154 | ```r
155 | library(shiny)
156 | shinyServer(function(input, output) {
157 | output$text <- renderText(input$slider1)
158 | })
159 | ```
160 |
161 | ## Slider App
162 |
163 | 
164 |
165 | ## New Components in the Slider App
166 |
167 | ### ui.R
168 |
169 | - `sliderInput()` specifies a slider that a user can manipulate
170 | - `testOutput()` displays text that is rendered in `server.R`
171 |
172 | ### server.R
173 |
174 | - `renderText()` transforms UI input into text that can be displayed.
175 |
176 | ## Inputs and Outputs
177 |
178 | Notice that in `ui.R` input and output names are assigned
179 | with strings (`sliderInput("slider1",...`, `textOutput("text")`)
180 | and in `server.R` those components can be accessed with the
181 | `$` operator: `output$text <- renderText(input$slider1)`.
182 |
183 | ## Apps with Plots
184 |
185 | Allowing users to manipulate data and to see the results of
186 | their manipulations as a plot can be very useful. Shiny
187 | provides the `plotOutput()` function for `ui.R` and the
188 | `renderPlot()` function for `sever.R` for taking user input
189 | and creating plots.
190 |
191 | ## Plot App: ui.R Part 1
192 |
193 | ```r
194 | library(shiny)
195 | shinyUI(fluidPage(
196 | titlePanel("Plot Random Numbers"),
197 | sidebarLayout(
198 | sidebarPanel(
199 | numericInput("numeric", "How Many Random Numbers Should be Plotted?",
200 | value = 1000, min = 1, max = 1000, step = 1),
201 | sliderInput("sliderX", "Pick Minimum and Maximum X Values",
202 | -100, 100, value = c(-50, 50)),
203 | # ...
204 | ```
205 |
206 | ## Plot App: ui.R Part 2
207 |
208 | ```r
209 | # ...
210 | sliderInput("sliderY", "Pick Minimum and Maximum Y Values",
211 | -100, 100, value = c(-50, 50)),
212 | checkboxInput("show_xlab", "Show/Hide X Axis Label", value = TRUE),
213 | checkboxInput("show_ylab", "Show/Hide Y Axis Label", value = TRUE),
214 | checkboxInput("show_title", "Show/Hide Title")
215 | ),
216 | mainPanel(
217 | h3("Graph of Random Points"),
218 | plotOutput("plot1")
219 | )
220 | )
221 | ))
222 | ```
223 |
224 | ## Plot App: server.R Part 1
225 |
226 | ```r
227 | library(shiny)
228 | shinyServer(function(input, output) {
229 | output$plot1 <- renderPlot({
230 | set.seed(2016-05-25)
231 | number_of_points <- input$numeric
232 | minX <- input$sliderX[1]
233 | maxX <- input$sliderX[2]
234 | minY <- input$sliderY[1]
235 | maxY <- input$sliderY[2]
236 | # ...
237 | ```
238 |
239 | ## Plot App: server.R Part 2
240 |
241 | ```r
242 | # ...
243 | dataX <- runif(number_of_points, minX, maxX)
244 | dataY <- runif(number_of_points, minY, maxY)
245 | xlab <- ifelse(input$show_xlab, "X Axis", "")
246 | ylab <- ifelse(input$show_ylab, "Y Axis", "")
247 | main <- ifelse(input$show_title, "Title", "")
248 | plot(dataX, dataY, xlab = xlab, ylab = ylab, main = main,
249 | xlim = c(-100, 100), ylim = c(-100, 100))
250 | })
251 | })
252 | ```
253 |
254 | ## Apps with Plots
255 |
256 | 
257 |
258 | ## Apps with Plots
259 |
260 | ### ui.R
261 |
262 | - `numericInput()` allows the user to enter any number
263 | - `checkboxInput()` creates boxes that can be checked
264 | - `plotOutput()` displays a plot
265 |
266 | ### server.R
267 |
268 | - `renderPlot()` wraps the creation of a plot so it can be displayed
269 |
270 | ## Next Lecture
271 |
272 | - Reactivity
273 | - Advanced UI
274 | - Interactive Graphics
275 |
276 | ## More about R and the Web
277 | - [OpenCPU](https://public.opencpu.org/) by Jerome Ooms, is a really neat project providing an API for calling R from web documents
278 |
--------------------------------------------------------------------------------
/Shiny_Part_1/Shiny_Part_1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/Shiny_Part_1/Shiny_Part_1.pdf
--------------------------------------------------------------------------------
/Shiny_Part_1/app1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/Shiny_Part_1/app1.png
--------------------------------------------------------------------------------
/Shiny_Part_1/app1/server.R:
--------------------------------------------------------------------------------
1 | library(shiny)
2 |
3 | shinyServer(function(input, output) {
4 |
5 | })
--------------------------------------------------------------------------------
/Shiny_Part_1/app1/ui.R:
--------------------------------------------------------------------------------
1 | library(shiny)
2 | shinyUI(fluidPage(
3 | titlePanel("Hello Shiny!"),
4 | sidebarLayout(
5 | sidebarPanel(
6 | h3("Sidebar")
7 | ),
8 |
9 | # Show a plot of the generated distribution
10 | mainPanel(
11 | h2("Hey")
12 | )
13 | )
14 | ))
--------------------------------------------------------------------------------
/Shiny_Part_1/app2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/Shiny_Part_1/app2.png
--------------------------------------------------------------------------------
/Shiny_Part_1/app2/server.R:
--------------------------------------------------------------------------------
1 | library(shiny)
2 | shinyServer(function(input, output) {
3 |
4 | })
--------------------------------------------------------------------------------
/Shiny_Part_1/app2/ui.R:
--------------------------------------------------------------------------------
1 | library(shiny)
2 | shinyUI(fluidPage(
3 | titlePanel("HTML Tags"),
4 | sidebarLayout(
5 | sidebarPanel(
6 | h1("H1 Text"),
7 | h3("H3 Text"),
8 | em("Emphasized Text")
9 | ),
10 | mainPanel(
11 | h3("Main Panel Text"),
12 | code("Some Code!")
13 | )
14 | )
15 | ))
--------------------------------------------------------------------------------
/Shiny_Part_1/app3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/Shiny_Part_1/app3.png
--------------------------------------------------------------------------------
/Shiny_Part_1/app3/server.R:
--------------------------------------------------------------------------------
1 | library(shiny)
2 | shinyServer(function(input, output) {
3 | output$text <- renderText(input$slider1)
4 | })
--------------------------------------------------------------------------------
/Shiny_Part_1/app3/ui.R:
--------------------------------------------------------------------------------
1 | library(shiny)
2 | shinyUI(fluidPage(
3 | titlePanel("Slider App"),
4 | sidebarLayout(
5 | sidebarPanel(
6 | h1("Move the Slider!"),
7 | sliderInput("slider1", "Slide Me!", 0, 100, 0)
8 | ),
9 | mainPanel(
10 | h3("Slider Value:"),
11 | textOutput("text")
12 | )
13 | )
14 | ))
--------------------------------------------------------------------------------
/Shiny_Part_1/app4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/Shiny_Part_1/app4.png
--------------------------------------------------------------------------------
/Shiny_Part_1/app4/server.R:
--------------------------------------------------------------------------------
1 | library(shiny)
2 | shinyServer(function(input, output) {
3 | output$plot1 <- renderPlot({
4 | set.seed(2016-05-25)
5 | number_of_points <- input$numeric
6 | minX <- input$sliderX[1]
7 | maxX <- input$sliderX[2]
8 | minY <- input$sliderY[1]
9 | maxY <- input$sliderY[2]
10 | dataX <- runif(number_of_points, minX, maxX)
11 | dataY <- runif(number_of_points, minY, maxY)
12 | xlab <- ifelse(input$show_xlab, "X Axis", "")
13 | ylab <- ifelse(input$show_ylab, "Y Axis", "")
14 | main <- ifelse(input$show_title, "Title", "")
15 | plot(dataX, dataY, xlab = xlab, ylab = ylab, main = main,
16 | xlim = c(-100, 100), ylim = c(-100, 100))
17 | })
18 | })
--------------------------------------------------------------------------------
/Shiny_Part_1/app4/ui.R:
--------------------------------------------------------------------------------
1 | library(shiny)
2 | shinyUI(fluidPage(
3 | titlePanel("Plot Random Numbers"),
4 | sidebarLayout(
5 | sidebarPanel(
6 | numericInput("numeric", "How Many Random Numbers Should be Plotted?",
7 | value = 1000, min = 1, max = 1000, step = 1),
8 | sliderInput("sliderX", "Pick Minimum and Maximum X Values",
9 | -100, 100, value = c(-50, 50)),
10 | sliderInput("sliderY", "Pick Minimum and Maximum Y Values",
11 | -100, 100, value = c(-50, 50)),
12 | checkboxInput("show_xlab", "Show/Hide X Axis Label", value = TRUE),
13 | checkboxInput("show_ylab", "Show/Hide Y Axis Label", value = TRUE),
14 | checkboxInput("show_title", "Show/Hide Title")
15 | ),
16 | mainPanel(
17 | h3("Graph of Random Points"),
18 | plotOutput("plot1")
19 | )
20 | )
21 | ))
--------------------------------------------------------------------------------
/Shiny_Part_2/Shiny_Part_2.Rmd:
--------------------------------------------------------------------------------
1 | ---
2 | title: 'Shiny: Part 2'
3 | author: "The Johns Hopkins Data Science Lab"
4 | always_allow_html: yes
5 | ---
6 |
7 | ## Reactivity
8 |
9 | A reactive expression is like a recipe that manipulates
10 | inputs from Shiny and then returns a value. Reactivity
11 | provides a way for your app to respond since inputs will
12 | change depending on how users interact with your user
13 | interface. Expressions wrapped by `reactive()` should be
14 | expressions that are subject to change.
15 |
16 | ## Reactivity
17 |
18 | Creating a reactive expression is just like creating a
19 | function:
20 |
21 | ```r
22 | calc_sum <- reactive({
23 | input$box1 + input$box2
24 | })
25 |
26 | # ...
27 |
28 | calc_sum()
29 | ```
30 |
31 | ## Your First Reactive App
32 |
33 | ```{r, echo=FALSE}
34 | library(webshot)
35 | appshot("app1", "app1.png")
36 | ```
37 |
38 | This application predicts the horsepower of a car given
39 | the fuel efficiency in miles per gallon for the car.
40 |
41 | ## Horsepower Prediction: ui.R Part 1
42 |
43 | ```r
44 | library(shiny)
45 | shinyUI(fluidPage(
46 | titlePanel("Predict Horsepower from MPG"),
47 | sidebarLayout(
48 | sidebarPanel(
49 | sliderInput("sliderMPG", "What is the MPG of the car?", 10, 35, value = 20),
50 | checkboxInput("showModel1", "Show/Hide Model 1", value = TRUE),
51 | checkboxInput("showModel2", "Show/Hide Model 2", value = TRUE)
52 | ),
53 | # ...
54 | ```
55 |
56 | ## Horsepower Prediction: ui.R Part 2
57 |
58 | ```r
59 | # ...
60 | mainPanel(
61 | plotOutput("plot1"),
62 | h3("Predicted Horsepower from Model 1:"),
63 | textOutput("pred1"),
64 | h3("Predicted Horsepower from Model 2:"),
65 | textOutput("pred2")
66 | )
67 | )
68 | ))
69 | ```
70 |
71 | ## Horsepower Prediction: server.R Part 1
72 |
73 | ```r
74 | library(shiny)
75 | shinyServer(function(input, output) {
76 | mtcars$mpgsp <- ifelse(mtcars$mpg - 20 > 0, mtcars$mpg - 20, 0)
77 | model1 <- lm(hp ~ mpg, data = mtcars)
78 | model2 <- lm(hp ~ mpgsp + mpg, data = mtcars)
79 |
80 | model1pred <- reactive({
81 | mpgInput <- input$sliderMPG
82 | predict(model1, newdata = data.frame(mpg = mpgInput))
83 | })
84 |
85 | model2pred <- reactive({
86 | mpgInput <- input$sliderMPG
87 | predict(model2, newdata =
88 | data.frame(mpg = mpgInput,
89 | mpgsp = ifelse(mpgInput - 20 > 0,
90 | mpgInput - 20, 0)))
91 | })
92 | ```
93 |
94 | ## Horsepower Prediction: server.R Part 2
95 |
96 | ```r
97 | output$plot1 <- renderPlot({
98 | mpgInput <- input$sliderMPG
99 |
100 | plot(mtcars$mpg, mtcars$hp, xlab = "Miles Per Gallon",
101 | ylab = "Horsepower", bty = "n", pch = 16,
102 | xlim = c(10, 35), ylim = c(50, 350))
103 | if(input$showModel1){
104 | abline(model1, col = "red", lwd = 2)
105 | }
106 | if(input$showModel2){
107 | model2lines <- predict(model2, newdata = data.frame(
108 | mpg = 10:35, mpgsp = ifelse(10:35 - 20 > 0, 10:35 - 20, 0)
109 | ))
110 | lines(10:35, model2lines, col = "blue", lwd = 2)
111 | }
112 | ```
113 |
114 | ## Horsepower Prediction: server.R Part 3
115 |
116 | ```r
117 | legend(25, 250, c("Model 1 Prediction", "Model 2 Prediction"), pch = 16,
118 | col = c("red", "blue"), bty = "n", cex = 1.2)
119 | points(mpgInput, model1pred(), col = "red", pch = 16, cex = 2)
120 | points(mpgInput, model2pred(), col = "blue", pch = 16, cex = 2)
121 | })
122 |
123 | output$pred1 <- renderText({
124 | model1pred()
125 | })
126 |
127 | output$pred2 <- renderText({
128 | model2pred()
129 | })
130 | })
131 | ```
132 |
133 | ## Horsepower Prediction
134 |
135 | 
136 |
137 | ## Delayed Reactivity
138 |
139 | You might not want your app to immediately react to changes
140 | in user input because of something like a long-running
141 | calculation. In order to prevent reactive expressions from
142 | reacting you can use a submit button in your app. Let's take
143 | a look at last app we created, but with a submit button
144 | added to the app.
145 |
146 | ```{r, echo=FALSE}
147 | library(webshot)
148 | appshot("app2", "app2.png")
149 | ```
150 |
151 | ## Reactive Horsepower: ui.R
152 |
153 | There's one new line added to the code from the last app:
154 |
155 | ```r
156 | shinyUI(fluidPage(
157 | titlePanel("Predict Horsepower from MPG"),
158 | sidebarLayout(
159 | sidebarPanel(
160 | sliderInput("sliderMPG", "What is the MPG of the car?", 10, 35, value = 20),
161 | checkboxInput("showModel1", "Show/Hide Model 1", value = TRUE),
162 | checkboxInput("showModel2", "Show/Hide Model 2", value = TRUE),
163 | submitButton("Submit") # New!
164 | ),
165 | ```
166 |
167 | ## Reactive Horsepower
168 |
169 | 
170 |
171 | ## Advanced UI
172 |
173 | There are several other kinds of UI components that you can
174 | mix into your app including tabs, navbars, and sidebars.
175 | We'll show you an example of how to use tabs to give your app
176 | multiple views. The `tabsetPanel()` function specifies a
177 | group of tabs, and then the `tabPanel()` function specifies
178 | the contents of an individual tab.
179 |
180 | ```{r, echo=FALSE}
181 | library(webshot)
182 | appshot("app3", "app3.png")
183 | ```
184 |
185 | ## Tabs: ui.R
186 |
187 | ```r
188 | library(shiny)
189 | shinyUI(fluidPage(
190 | titlePanel("Tabs!"),
191 | sidebarLayout(
192 | sidebarPanel(
193 | textInput("box1", "Enter Tab 1 Text:", value = "Tab 1!"),
194 | textInput("box2", "Enter Tab 2 Text:", value = "Tab 2!"),
195 | textInput("box3", "Enter Tab 3 Text:", value = "Tab 3!")
196 | ),
197 | mainPanel(
198 | tabsetPanel(type = "tabs",
199 | tabPanel("Tab 1", br(), textOutput("out1")),
200 | tabPanel("Tab 2", br(), textOutput("out2")),
201 | tabPanel("Tab 2", br(), textOutput("out3"))
202 | )
203 | )
204 | )
205 | ))
206 | ```
207 |
208 | ## Tabs: server.R
209 |
210 | ```r
211 | library(shiny)
212 | shinyServer(function(input, output) {
213 | output$out1 <- renderText(input$box1)
214 | output$out2 <- renderText(input$box2)
215 | output$out3 <- renderText(input$box3)
216 | })
217 | ```
218 |
219 | ## Tabs
220 |
221 | 
222 |
223 | ## Interactive Graphics
224 |
225 | One of my favorite features of Shiny is the ability to create
226 | graphics that a user can interact with. One method you can
227 | use to select multiple data points on a graph is
228 | by specifying the `brush` argument in `plotOutput()` on the
229 | `ui.R` side, and then using the `brushedPoints()` function on
230 | the `server.R` side. The following example app fits a
231 | linear model for the selected points and then draws a line
232 | of best fit for the resulting model.
233 |
234 | ```{r, echo=FALSE}
235 | library(webshot)
236 | appshot("app4", "app4.png")
237 | ```
238 |
239 | ## Interactive Graphics: ui.R
240 |
241 | ```r
242 | library(shiny)
243 | shinyUI(fluidPage(
244 | titlePanel("Visualize Many Models"),
245 | sidebarLayout(
246 | sidebarPanel(
247 | h3("Slope"),
248 | textOutput("slopeOut"),
249 | h3("Intercept"),
250 | textOutput("intOut")
251 | ),
252 | mainPanel(
253 | plotOutput("plot1", brush = brushOpts(
254 | id = "brush1"
255 | ))
256 | )
257 | )
258 | ))
259 | ```
260 |
261 | ## Interactive Graphics: server.R Part 1
262 |
263 | ```r
264 | library(shiny)
265 | shinyServer(function(input, output) {
266 | model <- reactive({
267 | brushed_data <- brushedPoints(trees, input$brush1,
268 | xvar = "Girth", yvar = "Volume")
269 | if(nrow(brushed_data) < 2){
270 | return(NULL)
271 | }
272 | lm(Volume ~ Girth, data = brushed_data)
273 | })
274 | output$slopeOut <- renderText({
275 | if(is.null(model())){
276 | "No Model Found"
277 | } else {
278 | model()[[1]][2]
279 | }
280 | })
281 | # ...
282 | ```
283 |
284 | ## Interactive Graphics: server.R Part 2
285 |
286 | ```r
287 | # ...
288 | output$intOut <- renderText({
289 | if(is.null(model())){
290 | "No Model Found"
291 | } else {
292 | model()[[1]][1]
293 | }
294 | })
295 | output$plot1 <- renderPlot({
296 | plot(trees$Girth, trees$Volume, xlab = "Girth",
297 | ylab = "Volume", main = "Tree Measurements",
298 | cex = 1.5, pch = 16, bty = "n")
299 | if(!is.null(model())){
300 | abline(model(), col = "blue", lwd = 2)
301 | }
302 | })
303 | })
304 | ```
305 |
306 | ## Interactive Graphics
307 |
308 | 
309 |
310 | ## Sharing Shiny Apps
311 |
312 | Once you've created a Shiny app, there are several ways to
313 | share your app. Using [shinyapps.io](http://www.shinyapps.io/)
314 | allows users to interact with your app through a web browser
315 | without needing to have R or Shiny installed. Shinyapps.io
316 | has a free tier, but if you want to use a Shiny app in your
317 | business you may be interested in paying for the service. If
318 | you're sharing your app with an R user you can post your app
319 | to GitHub and instruct the user to use the `runGist()` or
320 | `runGitHub()` function to launch your app.
321 |
322 | ## More Shiny Resources
323 |
324 | - [The Official Shiny Tutorial](http://shiny.rstudio.com/tutorial/)
325 | - [Gallery of Shiny Apps](http://shiny.rstudio.com/gallery/)
326 | - [Show Me Shiny: Gallery of R Web Apps](http://www.showmeshiny.com/)
327 | - [Integrating Shiny and Plotly](https://plot.ly/r/shiny-tutorial/)
328 | - [Shiny on Stack Overflow](http://stackoverflow.com/questions/tagged/shiny)
--------------------------------------------------------------------------------
/Shiny_Part_2/Shiny_Part_2.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/Shiny_Part_2/Shiny_Part_2.pdf
--------------------------------------------------------------------------------
/Shiny_Part_2/app1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/Shiny_Part_2/app1.png
--------------------------------------------------------------------------------
/Shiny_Part_2/app1/server.R:
--------------------------------------------------------------------------------
1 | library(shiny)
2 | shinyServer(function(input, output) {
3 | mtcars$mpgsp <- ifelse(mtcars$mpg - 20 > 0, mtcars$mpg - 20, 0)
4 | model1 <- lm(hp ~ mpg, data = mtcars)
5 | model2 <- lm(hp ~ mpgsp + mpg, data = mtcars)
6 |
7 | model1pred <- reactive({
8 | mpgInput <- input$sliderMPG
9 | predict(model1, newdata = data.frame(mpg = mpgInput))
10 | })
11 |
12 | model2pred <- reactive({
13 | mpgInput <- input$sliderMPG
14 | predict(model2, newdata =
15 | data.frame(mpg = mpgInput,
16 | mpgsp = ifelse(mpgInput - 20 > 0,
17 | mpgInput - 20, 0)))
18 | })
19 |
20 | output$plot1 <- renderPlot({
21 | mpgInput <- input$sliderMPG
22 |
23 | plot(mtcars$mpg, mtcars$hp, xlab = "Miles Per Gallon",
24 | ylab = "Horsepower", bty = "n", pch = 16,
25 | xlim = c(10, 35), ylim = c(50, 350))
26 | if(input$showModel1){
27 | abline(model1, col = "red", lwd = 2)
28 | }
29 | if(input$showModel2){
30 | model2lines <- predict(model2, newdata = data.frame(
31 | mpg = 10:35, mpgsp = ifelse(10:35 - 20 > 0, 10:35 - 20, 0)
32 | ))
33 | lines(10:35, model2lines, col = "blue", lwd = 2)
34 | }
35 | legend(25, 250, c("Model 1 Prediction", "Model 2 Prediction"), pch = 16,
36 | col = c("red", "blue"), bty = "n", cex = 1.2)
37 | points(mpgInput, model1pred(), col = "red", pch = 16, cex = 2)
38 | points(mpgInput, model2pred(), col = "blue", pch = 16, cex = 2)
39 | })
40 |
41 | output$pred1 <- renderText({
42 | model1pred()
43 | })
44 |
45 | output$pred2 <- renderText({
46 | model2pred()
47 | })
48 | })
--------------------------------------------------------------------------------
/Shiny_Part_2/app1/ui.R:
--------------------------------------------------------------------------------
1 | library(shiny)
2 | shinyUI(fluidPage(
3 | titlePanel("Predict Horsepower from MPG"),
4 | sidebarLayout(
5 | sidebarPanel(
6 | sliderInput("sliderMPG", "What is the MPG of the car?", 10, 35, value = 20),
7 | checkboxInput("showModel1", "Show/Hide Model 1", value = TRUE),
8 | checkboxInput("showModel2", "Show/Hide Model 2", value = TRUE)
9 | ),
10 | mainPanel(
11 | plotOutput("plot1"),
12 | h3("Predicted Horsepower from Model 1:"),
13 | textOutput("pred1"),
14 | h3("Predicted Horsepower from Model 2:"),
15 | textOutput("pred2")
16 | )
17 | )
18 | ))
--------------------------------------------------------------------------------
/Shiny_Part_2/app2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/Shiny_Part_2/app2.png
--------------------------------------------------------------------------------
/Shiny_Part_2/app2/server.R:
--------------------------------------------------------------------------------
1 | library(shiny)
2 | shinyServer(function(input, output) {
3 | mtcars$mpgsp <- ifelse(mtcars$mpg - 20 > 0, mtcars$mpg - 20, 0)
4 | model1 <- lm(hp ~ mpg, data = mtcars)
5 | model2 <- lm(hp ~ mpgsp + mpg, data = mtcars)
6 |
7 | model1pred <- reactive({
8 | mpgInput <- input$sliderMPG
9 | predict(model1, newdata = data.frame(mpg = mpgInput))
10 | })
11 |
12 | model2pred <- reactive({
13 | mpgInput <- input$sliderMPG
14 | predict(model2, newdata =
15 | data.frame(mpg = mpgInput,
16 | mpgsp = ifelse(mpgInput - 20 > 0,
17 | mpgInput - 20, 0)))
18 | })
19 |
20 | output$plot1 <- renderPlot({
21 | mpgInput <- input$sliderMPG
22 |
23 | plot(mtcars$mpg, mtcars$hp, xlab = "Miles Per Gallon",
24 | ylab = "Horsepower", bty = "n", pch = 16,
25 | xlim = c(10, 35), ylim = c(50, 350))
26 | if(input$showModel1){
27 | abline(model1, col = "red", lwd = 2)
28 | }
29 | if(input$showModel2){
30 | model2lines <- predict(model2, newdata = data.frame(
31 | mpg = 10:35, mpgsp = ifelse(10:35 - 20 > 0, 10:35 - 20, 0)
32 | ))
33 | lines(10:35, model2lines, col = "blue", lwd = 2)
34 | }
35 | legend(25, 250, c("Model 1 Prediction", "Model 2 Prediction"), pch = 16,
36 | col = c("red", "blue"), bty = "n", cex = 1.2)
37 | points(mpgInput, model1pred(), col = "red", pch = 16, cex = 2)
38 | points(mpgInput, model2pred(), col = "blue", pch = 16, cex = 2)
39 | })
40 |
41 | output$pred1 <- renderText({
42 | model1pred()
43 | })
44 |
45 | output$pred2 <- renderText({
46 | model2pred()
47 | })
48 | })
--------------------------------------------------------------------------------
/Shiny_Part_2/app2/ui.R:
--------------------------------------------------------------------------------
1 | library(shiny)
2 | shinyUI(fluidPage(
3 | titlePanel("Predict Horsepower from MPG"),
4 | sidebarLayout(
5 | sidebarPanel(
6 | sliderInput("sliderMPG", "What is the MPG of the car?", 10, 35, value = 20),
7 | checkboxInput("showModel1", "Show/Hide Model 1", value = TRUE),
8 | checkboxInput("showModel2", "Show/Hide Model 2", value = TRUE),
9 | submitButton("Submit")
10 | ),
11 | mainPanel(
12 | plotOutput("plot1"),
13 | h3("Predicted Horsepower from Model 1:"),
14 | textOutput("pred1"),
15 | h3("Predicted Horsepower from Model 2:"),
16 | textOutput("pred2")
17 | )
18 | )
19 | ))
--------------------------------------------------------------------------------
/Shiny_Part_2/app3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/Shiny_Part_2/app3.png
--------------------------------------------------------------------------------
/Shiny_Part_2/app3/server.R:
--------------------------------------------------------------------------------
1 | library(shiny)
2 | shinyServer(function(input, output) {
3 | output$out1 <- renderText(input$box1)
4 | output$out2 <- renderText(input$box2)
5 | output$out3 <- renderText(input$box3)
6 | })
--------------------------------------------------------------------------------
/Shiny_Part_2/app3/ui.R:
--------------------------------------------------------------------------------
1 | library(shiny)
2 | shinyUI(fluidPage(
3 | titlePanel("Tabs!"),
4 | sidebarLayout(
5 | sidebarPanel(
6 | textInput("box1", "Enter Tab 1 Text:", value = "Tab 1!"),
7 | textInput("box2", "Enter Tab 2 Text:", value = "Tab 2!"),
8 | textInput("box3", "Enter Tab 3 Text:", value = "Tab 3!")
9 | ),
10 | mainPanel(
11 | tabsetPanel(type = "tabs",
12 | tabPanel("Tab 1", br(), textOutput("out1")),
13 | tabPanel("Tab 2", br(), textOutput("out2")),
14 | tabPanel("Tab 2", br(), textOutput("out3"))
15 | )
16 | )
17 | )
18 | ))
--------------------------------------------------------------------------------
/Shiny_Part_2/app4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/Shiny_Part_2/app4.png
--------------------------------------------------------------------------------
/Shiny_Part_2/app4/server.R:
--------------------------------------------------------------------------------
1 | library(shiny)
2 | shinyServer(function(input, output) {
3 | model <- reactive({
4 | brushed_data <- brushedPoints(trees, input$brush1,
5 | xvar = "Girth", yvar = "Volume")
6 | if(nrow(brushed_data) < 2){
7 | return(NULL)
8 | }
9 | lm(Volume ~ Girth, data = brushed_data)
10 | })
11 |
12 | output$slopeOut <- renderText({
13 | if(is.null(model())){
14 | "No Model Found"
15 | } else {
16 | model()[[1]][2]
17 | }
18 | })
19 |
20 | output$intOut <- renderText({
21 | if(is.null(model())){
22 | "No Model Found"
23 | } else {
24 | model()[[1]][1]
25 | }
26 | })
27 |
28 | output$plot1 <- renderPlot({
29 | plot(trees$Girth, trees$Volume, xlab = "Girth",
30 | ylab = "Volume", main = "Tree Measurements",
31 | cex = 1.5, pch = 16, bty = "n")
32 | if(!is.null(model())){
33 | abline(model(), col = "blue", lwd = 2)
34 | }
35 | })
36 |
37 |
38 | })
--------------------------------------------------------------------------------
/Shiny_Part_2/app4/ui.R:
--------------------------------------------------------------------------------
1 | library(shiny)
2 | shinyUI(fluidPage(
3 | titlePanel("Visualize Many Models"),
4 | sidebarLayout(
5 | sidebarPanel(
6 | h3("Slope"),
7 | textOutput("slopeOut"),
8 | h3("Intercept"),
9 | textOutput("intOut")
10 | ),
11 | mainPanel(
12 | plotOutput("plot1", brush = brushOpts(
13 | id = "brush1"
14 | ))
15 | )
16 | )
17 | ))
--------------------------------------------------------------------------------
/bloomberg_shield.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/bloomberg_shield.png
--------------------------------------------------------------------------------
/book.Rmd:
--------------------------------------------------------------------------------
1 | ---
2 | ---
3 |
4 | # [Developing Data Products](index.html)
5 |
6 | ## Developing Data Products in R
7 |
8 | This companion book for the class introduces the topic of Developing Data Products in R. You can get a copy here: https://leanpub.com/ddp
9 |
10 | It has variable pricing, including free!
11 |
12 | 
13 |
14 | The book is available under variable pricing, including free! It also includes some content (like leaflet) that was not covered in the class and omits some other. It's a little rough, but as I work on it you'll get all of the updates.
15 |
16 | ---
17 |
18 | [**Back to Developing Data Products Home**](index.html)
--------------------------------------------------------------------------------
/book.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/book.pdf
--------------------------------------------------------------------------------
/book.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/book.png
--------------------------------------------------------------------------------
/build.R:
--------------------------------------------------------------------------------
1 | args <- commandArgs()
2 | library(rmarkdown)
3 |
4 | make_pdf <- FALSE
5 |
6 | needs_making <- function(source_file, goal_file){
7 | !file.exists(goal_file) || file.mtime(source_file) > file.mtime(goal_file)
8 | }
9 |
10 | rmds <- list.files(recursive = TRUE, pattern = "[r|R]md$")
11 | pdfs <- gsub("[r|R]md$", "pdf", rmds)
12 | htmls <- gsub("[r|R]md$", "html", rmds)
13 |
14 | if("clean" %in% args){
15 | for (i in seq_along(rmds)) {
16 | if(file.exists(pdfs[i])){
17 | unlink(pdfs[i], recursive = TRUE, force = TRUE)
18 | }
19 | if(file.exists(htmls[i])){
20 | unlink(htmls[i], recursive = TRUE, force = TRUE)
21 | }
22 | }
23 | stop("Cleaning Complete")
24 | }
25 |
26 | for(i in seq_along(rmds)){
27 | if(needs_making(rmds[i], htmls[i])){
28 | if(dirname(rmds[i]) == "."){
29 | render(rmds[i], output_format = html_document(toc = TRUE, toc_float = list(collapsed = FALSE),
30 | fig_caption = FALSE, theme = 'cosmo', toc_depth = 2),
31 | output_dir = dirname(rmds[i]))
32 | } else {
33 | render(rmds[i], output_format = ioslides_presentation(fig_height = 4.5,
34 | fig_caption = FALSE,
35 | logo = '../bloomberg_shield.png',
36 | css = '../slides.css'),
37 | output_dir = dirname(rmds[i]))
38 | }
39 | } else {
40 | print(rmds[i])
41 | print(htmls[i])
42 | }
43 |
44 | if(needs_making(rmds[i], pdfs[i]) && make_pdf){
45 | if(dirname(rmds[i]) == "."){
46 | render(rmds[i], output_format = pdf_document(fig_caption = FALSE),
47 | output_dir = dirname(rmds[i]))
48 | } else {
49 | render(rmds[i], output_format = beamer_presentation(fig_caption = FALSE),
50 | output_dir = dirname(rmds[i]))
51 | }
52 |
53 | } else {
54 | print(rmds[i])
55 | print(pdfs[i])
56 | }
57 | }
58 |
59 |
60 |
--------------------------------------------------------------------------------
/community.Rmd:
--------------------------------------------------------------------------------
1 | ---
2 | ---
3 |
4 | # [Developing Data Products](index.html)
5 |
6 | Since the beginning of the Data Science Specialization, we've noticed the unbelievable passion students have about our courses and the generosity they show toward each other on the course forums. A couple students have created quality content around the subjects we discuss, and many of these materials are so good we feel that they should be shared with all of our students.
7 |
8 | We're excited to announce that we've created a site using GitHub Pages: http://datasciencespecialization.github.io/ to serve as a directory for content that the community has created. If you've created materials relating to any of the courses in the Data Science Specialization, please send us a pull request so we can add a link to your content on our site. You can find out more about contributing here: https://github.com/DataScienceSpecialization/DataScienceSpecialization.github.io#contributing
9 |
10 | We can't wait to see what you've created and where the community can take this site!
11 |
12 | ---
13 |
14 | [**Back to Developing Data Products Home**](index.html)
--------------------------------------------------------------------------------
/community.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/community.pdf
--------------------------------------------------------------------------------
/googleVis/configoptions.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/configoptions.png
--------------------------------------------------------------------------------
/googleVis/googleVis.Rmd:
--------------------------------------------------------------------------------
1 | ---
2 | title: "googleVis"
3 | author: "The Johns Hopkins Data Science Lab"
4 | output:
5 | ioslides_presentation:
6 | logo: ../../img/bloomberg_shield.png
7 | beamer_presentation: default
8 | always_allow_html: yes
9 | ---
10 |
11 | ## Google Vis API
12 |
13 |
14 |
15 | https://developers.google.com/chart/interactive/docs/gallery
16 |
17 | ## Basic idea
18 |
19 | * The R function creates an HTML page
20 | * The HTML page calls Google Charts
21 | * The result is an interactive HTML graphic
22 |
23 | ## Example
24 |
25 | ```{r gv, results="asis", cache=TRUE}
26 | suppressPackageStartupMessages(library(googleVis))
27 | M <- gvisMotionChart(Fruits, "Fruit", "Year",
28 | options=list(width=600, height=400))
29 | print(M,"chart")
30 | ```
31 |
32 | ## Charts in googleVis
33 |
34 | "gvis + ChartType"
35 |
36 | * Motion charts: `gvisMotionChart`
37 | * Interactive maps: `gvisGeoChart`
38 | * Interactive tables: `gvisTable`
39 | * Line charts: `gvisLineChart`
40 | * Bar charts: `gvisColumnChart`
41 | * Tree maps: `gvisTreeMap`
42 |
43 | http://cran.r-project.org/web/packages/googleVis/googleVis.pdf
44 |
45 | ## Plots on maps
46 |
47 | ```{r,dependson="gv",results="asis", cache=TRUE}
48 | G <- gvisGeoChart(Exports, locationvar="Country",
49 | colorvar="Profit",options=list(width=600, height=400))
50 | print(G,"chart")
51 | ```
52 |
53 | ## Specifying a region
54 |
55 | ```{r,dependson="gv",results="asis", cache=TRUE}
56 | G2 <- gvisGeoChart(Exports, locationvar="Country",
57 | colorvar="Profit",options=list(width=600, height=400,region="150"))
58 | print(G2,"chart")
59 | ```
60 |
61 | ## Finding parameters to set under `options`
62 |
63 |
64 |
65 |
66 | https://developers.google.com/chart/interactive/docs/gallery/geochart
67 |
68 | ## Setting more options
69 |
70 | ```{r linechart,dependson="gv",results="asis", cache=TRUE}
71 | df <- data.frame(label=c("US", "GB", "BR"), val1=c(1,3,4), val2=c(23,12,32))
72 | Line <- gvisLineChart(df, xvar="label", yvar=c("val1","val2"),
73 | options=list(title="Hello World", legend="bottom",
74 | titleTextStyle="{color:'red', fontSize:18}",
75 | vAxis="{gridlines:{color:'red', count:3}}",
76 | hAxis="{title:'My Label', titleTextStyle:{color:'blue'}}",
77 | series="[{color:'green', targetAxisIndex: 0},
78 | {color: 'blue',targetAxisIndex:1}]",
79 | vAxes="[{title:'Value 1 (%)', format:'##,######%'},
80 | {title:'Value 2 (\U00A3)'}]",
81 | curveType="function", width=500, height=300
82 | ))
83 | ```
84 |
85 | https://github.com/mages/Introduction_to_googleVis/blob/gh-pages/index.Rmd
86 |
87 | ## Setting more options
88 |
89 | ```{r ,dependson="linechart",results="asis", cache=TRUE}
90 | print(Line,"chart")
91 | ```
92 |
93 | ## Combining multiple plots together
94 |
95 | ```{r multiplot,dependson="gv",results="asis", cache=TRUE}
96 | G <- gvisGeoChart(Exports, "Country", "Profit",options=list(width=200, height=100))
97 | T1 <- gvisTable(Exports,options=list(width=200, height=270))
98 | M <- gvisMotionChart(Fruits, "Fruit", "Year", options=list(width=400, height=370))
99 | GT <- gvisMerge(G,T1, horizontal=FALSE)
100 | GTM <- gvisMerge(GT, M, horizontal=TRUE,tableOptions="bgcolor=\"#CCCCCC\" cellspacing=10")
101 | ```
102 |
103 | ## Combining multiple plots together
104 |
105 | ```{r,dependson="multiplot",results="asis", cache=TRUE}
106 | print(GTM,"chart")
107 | ```
108 |
109 | ## Seeing the HTML code
110 |
111 | ```{r ,dependson="gv", cache=TRUE}
112 | M <- gvisMotionChart(Fruits, "Fruit", "Year", options=list(width=600, height=400))
113 | print(M)
114 | print(M, 'chart', file='myfilename.html')
115 | ```
116 |
117 | ## Things you can do with Google Vis
118 |
119 | * The visualizations can be embedded in websites with HTML code
120 | * Dynamic visualizations can be built with Shiny, Rook, and R.rsp
121 | * Embed them in [R markdown](http://www.rstudio.com/ide/docs/authoring/using_markdown) based documents
122 | * Set `results="asis"` in the chunk options
123 | * Can be used with [knitr](http://cran.r-project.org/web/packages/knitr/index.html) and [slidify](http://slidify.org/)
124 |
125 | ## For more info
126 |
127 | ```{r,eval=FALSE}
128 | demo(googleVis)
129 | ```
130 |
131 | * http://cran.r-project.org/web/packages/googleVis/vignettes/googleVis.pdf
132 | * http://cran.r-project.org/web/packages/googleVis/googleVis.pdf
133 | * https://developers.google.com/chart/interactive/docs/gallery
134 | * https://developers.google.com/chart/interactive/faq
135 |
--------------------------------------------------------------------------------
/googleVis/googleVis.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis.pdf
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/beamer/__packages:
--------------------------------------------------------------------------------
1 | base
2 | rmarkdown
3 | googleVis
4 |
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/beamer/gv_9dbf4e117f315a77fe16b769e9c0f6b2.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/beamer/gv_9dbf4e117f315a77fe16b769e9c0f6b2.RData
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/beamer/gv_9dbf4e117f315a77fe16b769e9c0f6b2.rdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/beamer/gv_9dbf4e117f315a77fe16b769e9c0f6b2.rdb
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/beamer/gv_9dbf4e117f315a77fe16b769e9c0f6b2.rdx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/beamer/gv_9dbf4e117f315a77fe16b769e9c0f6b2.rdx
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/beamer/linechart_6d9407505251a3dc7b7c5bc643d95ef2.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/beamer/linechart_6d9407505251a3dc7b7c5bc643d95ef2.RData
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/beamer/linechart_6d9407505251a3dc7b7c5bc643d95ef2.rdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/beamer/linechart_6d9407505251a3dc7b7c5bc643d95ef2.rdb
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/beamer/linechart_6d9407505251a3dc7b7c5bc643d95ef2.rdx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/beamer/linechart_6d9407505251a3dc7b7c5bc643d95ef2.rdx
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/beamer/multiplot_81494356bc1144eef8caa488a7bb2a92.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/beamer/multiplot_81494356bc1144eef8caa488a7bb2a92.RData
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/beamer/multiplot_81494356bc1144eef8caa488a7bb2a92.rdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/beamer/multiplot_81494356bc1144eef8caa488a7bb2a92.rdb
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/beamer/multiplot_81494356bc1144eef8caa488a7bb2a92.rdx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/beamer/multiplot_81494356bc1144eef8caa488a7bb2a92.rdx
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/beamer/unnamed-chunk-1_b7ded69b4296a4724bf3375d4ab84970.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/beamer/unnamed-chunk-1_b7ded69b4296a4724bf3375d4ab84970.RData
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/beamer/unnamed-chunk-1_b7ded69b4296a4724bf3375d4ab84970.rdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/beamer/unnamed-chunk-1_b7ded69b4296a4724bf3375d4ab84970.rdb
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/beamer/unnamed-chunk-1_b7ded69b4296a4724bf3375d4ab84970.rdx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/beamer/unnamed-chunk-1_b7ded69b4296a4724bf3375d4ab84970.rdx
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/beamer/unnamed-chunk-2_efae6bac495a80e9785c5fb8f683e7f3.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/beamer/unnamed-chunk-2_efae6bac495a80e9785c5fb8f683e7f3.RData
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/beamer/unnamed-chunk-2_efae6bac495a80e9785c5fb8f683e7f3.rdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/beamer/unnamed-chunk-2_efae6bac495a80e9785c5fb8f683e7f3.rdb
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/beamer/unnamed-chunk-2_efae6bac495a80e9785c5fb8f683e7f3.rdx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/beamer/unnamed-chunk-2_efae6bac495a80e9785c5fb8f683e7f3.rdx
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/beamer/unnamed-chunk-3_7713fa4fbd9d096e5db651140534175f.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/beamer/unnamed-chunk-3_7713fa4fbd9d096e5db651140534175f.RData
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/beamer/unnamed-chunk-3_7713fa4fbd9d096e5db651140534175f.rdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/beamer/unnamed-chunk-3_7713fa4fbd9d096e5db651140534175f.rdb
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/beamer/unnamed-chunk-3_7713fa4fbd9d096e5db651140534175f.rdx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/beamer/unnamed-chunk-3_7713fa4fbd9d096e5db651140534175f.rdx
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/beamer/unnamed-chunk-4_a03d382b0ff99902a3292da4c4a82599.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/beamer/unnamed-chunk-4_a03d382b0ff99902a3292da4c4a82599.RData
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/beamer/unnamed-chunk-4_a03d382b0ff99902a3292da4c4a82599.rdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/beamer/unnamed-chunk-4_a03d382b0ff99902a3292da4c4a82599.rdb
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/beamer/unnamed-chunk-4_a03d382b0ff99902a3292da4c4a82599.rdx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/beamer/unnamed-chunk-4_a03d382b0ff99902a3292da4c4a82599.rdx
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/beamer/unnamed-chunk-5_ad9f43e8c2a360e1874f7dacbb669bb0.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/beamer/unnamed-chunk-5_ad9f43e8c2a360e1874f7dacbb669bb0.RData
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/beamer/unnamed-chunk-5_ad9f43e8c2a360e1874f7dacbb669bb0.rdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/beamer/unnamed-chunk-5_ad9f43e8c2a360e1874f7dacbb669bb0.rdb
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/beamer/unnamed-chunk-5_ad9f43e8c2a360e1874f7dacbb669bb0.rdx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/beamer/unnamed-chunk-5_ad9f43e8c2a360e1874f7dacbb669bb0.rdx
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/html/__packages:
--------------------------------------------------------------------------------
1 | base
2 | rmarkdown
3 | googleVis
4 |
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/html/gv_0a8fdc426d8671280678fb7168963fe4.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/html/gv_0a8fdc426d8671280678fb7168963fe4.RData
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/html/gv_0a8fdc426d8671280678fb7168963fe4.rdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/html/gv_0a8fdc426d8671280678fb7168963fe4.rdb
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/html/gv_0a8fdc426d8671280678fb7168963fe4.rdx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/html/gv_0a8fdc426d8671280678fb7168963fe4.rdx
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/html/linechart_569775eca9978142a8076e308950de12.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/html/linechart_569775eca9978142a8076e308950de12.RData
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/html/linechart_569775eca9978142a8076e308950de12.rdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/html/linechart_569775eca9978142a8076e308950de12.rdb
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/html/linechart_569775eca9978142a8076e308950de12.rdx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/html/linechart_569775eca9978142a8076e308950de12.rdx
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/html/multiplot_d5d31575388fbf6e6e4344cb9a4bfb05.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/html/multiplot_d5d31575388fbf6e6e4344cb9a4bfb05.RData
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/html/multiplot_d5d31575388fbf6e6e4344cb9a4bfb05.rdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/html/multiplot_d5d31575388fbf6e6e4344cb9a4bfb05.rdb
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/html/multiplot_d5d31575388fbf6e6e4344cb9a4bfb05.rdx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/html/multiplot_d5d31575388fbf6e6e4344cb9a4bfb05.rdx
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/html/unnamed-chunk-1_2151b3fddc27c781204361ae4cb7006f.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/html/unnamed-chunk-1_2151b3fddc27c781204361ae4cb7006f.RData
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/html/unnamed-chunk-1_2151b3fddc27c781204361ae4cb7006f.rdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/html/unnamed-chunk-1_2151b3fddc27c781204361ae4cb7006f.rdb
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/html/unnamed-chunk-1_2151b3fddc27c781204361ae4cb7006f.rdx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/html/unnamed-chunk-1_2151b3fddc27c781204361ae4cb7006f.rdx
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/html/unnamed-chunk-2_8c5f47573f056c33ee195a276fe79ccf.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/html/unnamed-chunk-2_8c5f47573f056c33ee195a276fe79ccf.RData
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/html/unnamed-chunk-2_8c5f47573f056c33ee195a276fe79ccf.rdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/html/unnamed-chunk-2_8c5f47573f056c33ee195a276fe79ccf.rdb
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/html/unnamed-chunk-2_8c5f47573f056c33ee195a276fe79ccf.rdx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/html/unnamed-chunk-2_8c5f47573f056c33ee195a276fe79ccf.rdx
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/html/unnamed-chunk-3_32f836fbc28a7813a13da4bc6ef117cf.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/html/unnamed-chunk-3_32f836fbc28a7813a13da4bc6ef117cf.RData
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/html/unnamed-chunk-3_32f836fbc28a7813a13da4bc6ef117cf.rdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/html/unnamed-chunk-3_32f836fbc28a7813a13da4bc6ef117cf.rdb
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/html/unnamed-chunk-3_32f836fbc28a7813a13da4bc6ef117cf.rdx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/html/unnamed-chunk-3_32f836fbc28a7813a13da4bc6ef117cf.rdx
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/html/unnamed-chunk-4_1b442c01a204760130458afb0764aa97.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/html/unnamed-chunk-4_1b442c01a204760130458afb0764aa97.RData
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/html/unnamed-chunk-4_1b442c01a204760130458afb0764aa97.rdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/html/unnamed-chunk-4_1b442c01a204760130458afb0764aa97.rdb
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/html/unnamed-chunk-4_1b442c01a204760130458afb0764aa97.rdx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/html/unnamed-chunk-4_1b442c01a204760130458afb0764aa97.rdx
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/html/unnamed-chunk-5_d22b6d2206374fee4b1232cafb9ca68c.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/html/unnamed-chunk-5_d22b6d2206374fee4b1232cafb9ca68c.RData
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/html/unnamed-chunk-5_d22b6d2206374fee4b1232cafb9ca68c.rdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/html/unnamed-chunk-5_d22b6d2206374fee4b1232cafb9ca68c.rdb
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/html/unnamed-chunk-5_d22b6d2206374fee4b1232cafb9ca68c.rdx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/html/unnamed-chunk-5_d22b6d2206374fee4b1232cafb9ca68c.rdx
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/latex/__packages:
--------------------------------------------------------------------------------
1 | base
2 | rmarkdown
3 | googleVis
4 | bookdown
5 | tibble
6 | knitr
7 | stringr
8 | xml2
9 | rvest
10 | magrittr
11 | purrr
12 | dplyr
13 | tidytext
14 | tidyr
15 | ggplot2
16 | plotly
17 | swirl
18 |
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/latex/gv_f1b84de98bbecb16e7a2e7c32e1e3331.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/latex/gv_f1b84de98bbecb16e7a2e7c32e1e3331.RData
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/latex/gv_f1b84de98bbecb16e7a2e7c32e1e3331.rdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/latex/gv_f1b84de98bbecb16e7a2e7c32e1e3331.rdb
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/latex/gv_f1b84de98bbecb16e7a2e7c32e1e3331.rdx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/latex/gv_f1b84de98bbecb16e7a2e7c32e1e3331.rdx
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/latex/linechart_a9bf7d9448de24ede1ed7a3a532ebd7f.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/latex/linechart_a9bf7d9448de24ede1ed7a3a532ebd7f.RData
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/latex/linechart_a9bf7d9448de24ede1ed7a3a532ebd7f.rdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/latex/linechart_a9bf7d9448de24ede1ed7a3a532ebd7f.rdb
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/latex/linechart_a9bf7d9448de24ede1ed7a3a532ebd7f.rdx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/latex/linechart_a9bf7d9448de24ede1ed7a3a532ebd7f.rdx
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/latex/multiplot_47c2d2feef376bcebba06211e93e2cb6.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/latex/multiplot_47c2d2feef376bcebba06211e93e2cb6.RData
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/latex/multiplot_47c2d2feef376bcebba06211e93e2cb6.rdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/latex/multiplot_47c2d2feef376bcebba06211e93e2cb6.rdb
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/latex/multiplot_47c2d2feef376bcebba06211e93e2cb6.rdx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/latex/multiplot_47c2d2feef376bcebba06211e93e2cb6.rdx
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/latex/unnamed-chunk-1_b00967b2f56f36d4c63de3d0550d6595.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/latex/unnamed-chunk-1_b00967b2f56f36d4c63de3d0550d6595.RData
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/latex/unnamed-chunk-1_b00967b2f56f36d4c63de3d0550d6595.rdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/latex/unnamed-chunk-1_b00967b2f56f36d4c63de3d0550d6595.rdb
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/latex/unnamed-chunk-1_b00967b2f56f36d4c63de3d0550d6595.rdx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/latex/unnamed-chunk-1_b00967b2f56f36d4c63de3d0550d6595.rdx
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/latex/unnamed-chunk-2_83bd0699e86a757bca393975321fa2ce.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/latex/unnamed-chunk-2_83bd0699e86a757bca393975321fa2ce.RData
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/latex/unnamed-chunk-2_83bd0699e86a757bca393975321fa2ce.rdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/latex/unnamed-chunk-2_83bd0699e86a757bca393975321fa2ce.rdb
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/latex/unnamed-chunk-2_83bd0699e86a757bca393975321fa2ce.rdx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/latex/unnamed-chunk-2_83bd0699e86a757bca393975321fa2ce.rdx
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/latex/unnamed-chunk-3_af5165f1511c3967e4e94eb08dd7af05.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/latex/unnamed-chunk-3_af5165f1511c3967e4e94eb08dd7af05.RData
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/latex/unnamed-chunk-3_af5165f1511c3967e4e94eb08dd7af05.rdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/latex/unnamed-chunk-3_af5165f1511c3967e4e94eb08dd7af05.rdb
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/latex/unnamed-chunk-3_af5165f1511c3967e4e94eb08dd7af05.rdx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/latex/unnamed-chunk-3_af5165f1511c3967e4e94eb08dd7af05.rdx
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/latex/unnamed-chunk-4_82eb54c46b490101dad623ca487b52b9.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/latex/unnamed-chunk-4_82eb54c46b490101dad623ca487b52b9.RData
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/latex/unnamed-chunk-4_82eb54c46b490101dad623ca487b52b9.rdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/latex/unnamed-chunk-4_82eb54c46b490101dad623ca487b52b9.rdb
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/latex/unnamed-chunk-4_82eb54c46b490101dad623ca487b52b9.rdx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/latex/unnamed-chunk-4_82eb54c46b490101dad623ca487b52b9.rdx
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/latex/unnamed-chunk-5_21ff6d18310a5d2c21111b0a5cd09469.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/latex/unnamed-chunk-5_21ff6d18310a5d2c21111b0a5cd09469.RData
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/latex/unnamed-chunk-5_21ff6d18310a5d2c21111b0a5cd09469.rdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/latex/unnamed-chunk-5_21ff6d18310a5d2c21111b0a5cd09469.rdb
--------------------------------------------------------------------------------
/googleVis/googleVis_cache/latex/unnamed-chunk-5_21ff6d18310a5d2c21111b0a5cd09469.rdx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googleVis_cache/latex/unnamed-chunk-5_21ff6d18310a5d2c21111b0a5cd09469.rdx
--------------------------------------------------------------------------------
/googleVis/googlecharts.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/googleVis/googlecharts.png
--------------------------------------------------------------------------------
/googleVis/myfilename.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
172 |
173 |
--------------------------------------------------------------------------------
/index.Rmd:
--------------------------------------------------------------------------------
1 | ---
2 | ---
3 |
4 | # [Developing Data Products](index.html)
5 |
6 | ## Instructor
7 |
8 | - [Brian Caffo](http://www.bcaffo.com/)
9 |
10 | ## Class Website
11 |
12 | - [Developing Data Products on Coursera.org](https://www.coursera.org/learn/data-products)
13 |
14 | ## Textbook
15 |
16 | - [Developing Data Products in R](https://leanpub.com/ddp)
17 |
18 |
19 | ## Course Materials
20 |
21 | | Week/Lecture | Lecture | Video | Notes | Code |
22 | |:------------|:------------|:------------|:------------|:------------|
23 | | 1/1 | Welcome | --- | [html](welcome.html) [pdf](welcome.pdf)| --- |
24 | | 1/2 | Syllabus | --- | [html](syllabus.html) [pdf](syllabus.pdf)| --- |
25 | | 1/3 | Book: Developing Data Products in R | --- | [html](book.html) [pdf](book.pdf) | --- |
26 | | 1/4 | Data Science Specialization Community Site | --- | [html](community.html) [pdf](community.pdf) | --- |
27 | | 1/5 | Shiny: Reading | --- | [html](shiny.html) [pdf](shiny.pdf)| --- |
28 | | 1/6 | Shiny: Part 1 | Part [1][shiny11] [2][shiny12] [3][shiny13] [4][shiny14] [5][shiny15] | [html](./Shiny_Part_1/Shiny_Part_1.html) [pdf](./Shiny_Part_1/Shiny_Part_1.pdf)| --- |
29 | | 1/7 | Shiny: Part 2 | Part [1][shiny21] [2][shiny22] [3][shiny23] [4][shiny24] [5][shiny25] [6][shiny26] | [html](./Shiny_Part_2/Shiny_Part_2.html) [pdf](./Shiny_Part_2/Shiny_Part_2.pdf)| --- |
30 | | 1/8 | Shiny Gadgets | --- | [html](./Shiny_Gadgets/Shiny_Gadgets.html) [pdf](./Shiny_Gadgets/Shiny_Gadgets.pdf)| --- |
31 | | 1/9 | shinyapps.io Project | --- | [html](shinyproject.html) [pdf](shinyproject.pdf)| --- |
32 | | 1/10 | GoogleVis | --- | [html](./googleVis/googleVis.html) [pdf](./googleVis/googleVis.pdf)| --- |
33 | | 1/11 | Plotly | --- | [html](./plotly/plotly.html) [pdf](./plotly/plotly.pdf)| --- |
34 | | --- | --- | --- | --- | --- |
35 | | 2/1 | R Markdown | --- | [html](./R_Markdown/R_Markdown.html) [pdf](./R_Markdown/R_Markdown.pdf)| --- |
36 | | 2/2 | Sharing R Markdown Documents | --- | [html](./sharingrmd.html) [pdf](./sharingrmd.pdf)| --- |
37 | | 2/3 | Leaflet | --- | [html](./leaflet/leaflet.html) [pdf](./leaflet/leaflet.pdf)| --- |
38 | | --- | --- | --- | --- | --- |
39 | | 3/1 | R Packages | --- | [html](./RPackages/rpackages.html) [pdf](./RPackages/rpackages.pdf)| --- |
40 | | 3/2 | Classes & Methods | --- | [html](./Classes_and_Methods/Classes_and_Methods.html) [pdf](./Classes_and_Methods/Classes_and_Methods.pdf)| --- |
41 | | --- | --- | --- | --- | --- |
42 | | 4/1 | Swirl Courses | --- | [html](./swirl/swirl.html) [pdf](./swirl/swirl.pdf)| --- |
43 |
44 | ## Resources
45 |
46 | - [Installing R for Windows](https://www.youtube.com/watch?v=LII6of-5Odw)
47 | - [Installing R for Mac](https://www.youtube.com/watch?v=xokJUwn0mis)
48 | - [Installing RStudio Mac](https://www.youtube.com/watch?v=JbTMvQ-SbvQ)
49 |
50 | - [Rstudio](http://www.rstudio.com/), [R project](http://www.r-project.org/)
51 | - [Rstudio's cheatsheets](http://www.rstudio.com/resources/cheatsheets/)
52 |
53 | [shiny11]: https://drive.google.com/open?id=0B4QrfwPyx_SQcUdiWXRNa0Rza0U
54 | [shiny12]: https://drive.google.com/open?id=0B4QrfwPyx_SQeXlPSjQyaTcxRTA
55 | [shiny13]: https://drive.google.com/open?id=0B4QrfwPyx_SQZHBVZThHaWhFRzg
56 | [shiny14]: https://drive.google.com/open?id=0B4QrfwPyx_SQdDBPRVVROG9JS2M
57 | [shiny15]: https://drive.google.com/open?id=0B4QrfwPyx_SQbUxkS2w3Wnhybm8
58 | [shiny21]: https://drive.google.com/open?id=0B4QrfwPyx_SQLU9BcUtZbFF5Rnc
59 | [shiny22]: https://drive.google.com/open?id=0B4QrfwPyx_SQZGw1aW1FenVSQm8
60 | [shiny23]: https://drive.google.com/open?id=0B4QrfwPyx_SQQ25nZUxiZXVjdTQ
61 | [shiny24]: https://drive.google.com/open?id=0B4QrfwPyx_SQcllJX1ZETVNXU2M
62 | [shiny25]: https://drive.google.com/open?id=0B4QrfwPyx_SQYldUdjdLYkt2RlU
63 | [shiny26]: https://drive.google.com/open?id=0B4QrfwPyx_SQUnVMQ0lSVkNJY0k
64 | [shinyg1]: https://drive.google.com/open?id=0B4QrfwPyx_SQNHFIckl2NDJzalk
65 | [shinyg2]: https://drive.google.com/open?id=0B4QrfwPyx_SQT1A4U0dwTVpkbTQ
66 | [shinyg3]: https://drive.google.com/open?id=0B4QrfwPyx_SQZnNqOEcwOF9lMFk
67 |
68 |
--------------------------------------------------------------------------------
/index.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/index.pdf
--------------------------------------------------------------------------------
/leaflet/leaflet.Rmd:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Leaflet"
3 | author: "The Johns Hopkins Data Science Lab"
4 | always_allow_html: yes
5 | ---
6 |
7 | ## Introduction
8 |
9 | Leaflet is one of the most popular Javascript libraries for
10 | creating interactive maps. The leaflet R package allows you
11 | to create your own leaflet maps without needing to know any
12 | Javascript!
13 |
14 | ### Installation
15 |
16 | ```r
17 | install.packages("leaflet")
18 | ```
19 |
20 | ## Your First Map
21 |
22 | Getting started with leaflet is easy. The `leaflet()`
23 | function creates a map widget that you can store in a
24 | variable so that you can modify the map later on. You can
25 | add features to the map using the pipe operator (`%>%`) just
26 | like in dplyr. The `addTiles()` function adds mapping data
27 | from [Open Street Map](http://www.openstreetmap.org/).
28 |
29 | ```{r, eval=FALSE}
30 | library(leaflet)
31 | my_map <- leaflet() %>%
32 | addTiles()
33 | my_map
34 | ```
35 |
36 | ## Your First Map
37 |
38 | ```{r, echo=FALSE}
39 | library(leaflet)
40 | my_map <- leaflet() %>%
41 | addTiles()
42 | my_map
43 | ```
44 |
45 | ## Adding Markers
46 |
47 | You can add markers to your map one at a time using the
48 | `addMarkers()` function by specifying the longitude and
49 | latitude. ([Here's](https://twitter.com/drob/status/719927537330040832)
50 | a tip if you tend to mix them up.) You can specify popup
51 | text for when you click on the marker with the `popup`
52 | argument.
53 |
54 | ```{r, eval=FALSE}
55 | library(leaflet)
56 | my_map <- my_map %>%
57 | addMarkers(lat=39.2980803, lng=-76.5898801,
58 | popup="Jeff Leek's Office")
59 | my_map
60 | ```
61 |
62 | ## Adding Markers
63 |
64 | ```{r, echo=FALSE}
65 | library(leaflet)
66 | my_map <- my_map %>%
67 | addMarkers(lat=39.2980803, lng=-76.5898801,
68 | popup="Jeff Leek's Office")
69 | my_map
70 | ```
71 |
72 | ## Adding Many Markers
73 |
74 | Adding one marker at a time is often not practical if you
75 | want to display many markers. If you have a data frame with
76 | columns `lat` and `lng` you can pipe that data frame into
77 | `leaflet()` to add all the points at once.
78 |
79 | ```{r, eval=FALSE}
80 | set.seed(2016-04-25)
81 | df <- data.frame(lat = runif(20, min = 39.2, max = 39.3),
82 | lng = runif(20, min = -76.6, max = -76.5))
83 | df %>%
84 | leaflet() %>%
85 | addTiles() %>%
86 | addMarkers()
87 | ```
88 |
89 | ## Adding Many Markers
90 |
91 | ```{r, echo=FALSE}
92 | set.seed(2016-04-25)
93 | df <- data.frame(lat = runif(20, min = 39.2, max = 39.3),
94 | lng = runif(20, min = -76.6, max = -76.5))
95 | df %>%
96 | leaflet() %>%
97 | addTiles() %>%
98 | addMarkers()
99 | ```
100 |
101 | ## Making Custom Markers
102 |
103 | The blue markers that leaflet comes packaged with may not be
104 | enough depending on what you're mapping. Thankfully you can
105 | make your own markers from `.png` files.
106 |
107 | ```{r, eval=FALSE}
108 | hopkinsIcon <- makeIcon(
109 | iconUrl = "http://brand.jhu.edu/content/uploads/2014/06/university.shield.small_.blue_.png",
110 | iconWidth = 31*215/230, iconHeight = 31,
111 | iconAnchorX = 31*215/230/2, iconAnchorY = 16
112 | )
113 |
114 | hopkinsLatLong <- data.frame(
115 | lat = c(39.2973166, 39.3288851, 39.2906617),
116 | lng = c(-76.5929798, -76.6206598, -76.5469683))
117 |
118 | hopkinsLatLong %>%
119 | leaflet() %>%
120 | addTiles() %>%
121 | addMarkers(icon = hopkinsIcon)
122 | ```
123 |
124 | ## Making Custom Markers
125 |
126 | ```{r, echo=FALSE}
127 | hopkinsIcon <- makeIcon(
128 | iconUrl = "http://brand.jhu.edu/content/uploads/2014/06/university.shield.small_.blue_.png",
129 | iconWidth = 31*215/230, iconHeight = 31,
130 | iconAnchorX = 31*215/230/2, iconAnchorY = 16
131 | )
132 |
133 | hopkinsLatLong <- data.frame(
134 | lat = c(39.2973166, 39.3288851, 39.2906617, 39.2970681, 39.2824806),
135 | lng = c(-76.5929798, -76.6206598, -76.5469683, -76.6150537, -76.6016766))
136 |
137 | hopkinsLatLong %>%
138 | leaflet() %>%
139 | addTiles() %>%
140 | addMarkers(icon = hopkinsIcon)
141 | ```
142 |
143 | ## Adding Multiple Popups
144 |
145 | When adding multiple markers to a map, you may want to add
146 | popups for each marker. You can specify a string of plain
147 | text for each popup, or you can provide HTML which will be
148 | rendered inside of each popup.
149 |
150 | ```{r, eval=FALSE}
151 | hopkinsSites <- c(
152 | "East Baltimore Campus",
153 | "Homewood Campus",
154 | "Bayview Medical Center",
155 | "Peabody Institute",
156 | "Carey Business School"
157 | )
158 |
159 | hopkinsLatLong %>%
160 | leaflet() %>%
161 | addTiles() %>%
162 | addMarkers(icon = hopkinsIcon, popup = hopkinsSites)
163 | ```
164 |
165 | ## Adding Multiple Popups
166 |
167 | ```{r, echo=FALSE}
168 | hopkinsSites <- c(
169 | "East Baltimore Campus",
170 | "Homewood Campus",
171 | "Bayview Medical Center",
172 | "Peabody Institute",
173 | "Carey Business School"
174 | )
175 |
176 | hopkinsLatLong %>%
177 | leaflet() %>%
178 | addTiles() %>%
179 | addMarkers(icon = hopkinsIcon, popup = hopkinsSites)
180 | ```
181 |
182 | ## Mapping Clusters
183 |
184 | Sometimes you might have so many points on a map that it
185 | doesn't make sense to plot every marker. In these situations
186 | leaflet allows you to plot clusters of markers using
187 | `addMarkers(clusterOptions = markerClusterOptions())`. When
188 | you zoom in to each cluster, the clusters will separate until
189 | you can see the individual markers.
190 |
191 | ```{r, eval=FALSE}
192 | df <- data.frame(lat = runif(500, min = 39.25, max = 39.35),
193 | lng = runif(500, min = -76.65, max = -76.55))
194 | df %>%
195 | leaflet() %>%
196 | addTiles() %>%
197 | addMarkers(clusterOptions = markerClusterOptions())
198 | ```
199 |
200 | ## Mapping Clusters
201 |
202 | ```{r, echo=FALSE}
203 | df <- data.frame(lat = runif(500, min = 39.25, max = 39.35),
204 | lng = runif(500, min = -76.65, max = -76.55))
205 | df %>%
206 | leaflet() %>%
207 | addTiles() %>%
208 | addMarkers(clusterOptions = markerClusterOptions())
209 | ```
210 |
211 | ## Mapping Circle Markers
212 |
213 | Instead of adding markers or clusters you can easily add
214 | circle markers using `addCircleMarkers()`.
215 |
216 | ```{r, eval=FALSE}
217 | df <- data.frame(lat = runif(20, min = 39.25, max = 39.35),
218 | lng = runif(20, min = -76.65, max = -76.55))
219 | df %>%
220 | leaflet() %>%
221 | addTiles() %>%
222 | addCircleMarkers()
223 | ```
224 |
225 | ## Mapping Circle Markers
226 |
227 | ```{r, echo=FALSE}
228 | df <- data.frame(lat = runif(20, min = 39.25, max = 39.35),
229 | lng = runif(20, min = -76.65, max = -76.55))
230 | df %>%
231 | leaflet() %>%
232 | addTiles() %>%
233 | addCircleMarkers()
234 | ```
235 |
236 | ## Drawing Circles
237 |
238 | You can draw arbitrary shapes on the maps you create,
239 | including circles and squares. The code below draws a map
240 | where the circle on each city is proportional to the
241 | population of that city.
242 |
243 | ```{r, eval=FALSE}
244 | md_cities <- data.frame(name = c("Baltimore", "Frederick", "Rockville", "Gaithersburg",
245 | "Bowie", "Hagerstown", "Annapolis", "College Park", "Salisbury", "Laurel"),
246 | pop = c(619493, 66169, 62334, 61045, 55232,
247 | 39890, 38880, 30587, 30484, 25346),
248 | lat = c(39.2920592, 39.4143921, 39.0840, 39.1434, 39.0068, 39.6418, 38.9784, 38.9897, 38.3607, 39.0993),
249 | lng = c(-76.6077852, -77.4204875, -77.1528, -77.2014, -76.7791, -77.7200, -76.4922, -76.9378, -75.5994, -76.8483))
250 | md_cities %>%
251 | leaflet() %>%
252 | addTiles() %>%
253 | addCircles(weight = 1, radius = sqrt(md_cities$pop) * 30)
254 | ```
255 |
256 | ## Drawing Circles
257 |
258 | ```{r, echo=FALSE}
259 | md_cities <- data.frame(name = c("Baltimore", "Frederick", "Rockville", "Gaithersburg",
260 | "Bowie", "Hagerstown", "Annapolis", "College Park", "Salisbury", "Laurel"),
261 | pop = c(619493, 66169, 62334, 61045, 55232,
262 | 39890, 38880, 30587, 30484, 25346),
263 | lat = c(39.2920592, 39.4143921, 39.0840, 39.1434, 39.0068, 39.6418, 38.9784, 38.9897, 38.3607, 39.0993),
264 | lng = c(-76.6077852, -77.4204875, -77.1528, -77.2014, -76.7791, -77.7200, -76.4922, -76.9378, -75.5994, -76.8483))
265 | md_cities %>%
266 | leaflet() %>%
267 | addTiles() %>%
268 | addCircles(weight = 1, radius = sqrt(md_cities$pop) * 30)
269 | ```
270 |
271 | ## Drawing Rectangles
272 |
273 | You can add rectangles on leaflet maps as well:
274 |
275 | ```{r, eval=FALSE}
276 | leaflet() %>%
277 | addTiles() %>%
278 | addRectangles(lat1 = 37.3858, lng1 = -122.0595,
279 | lat2 = 37.3890, lng2 = -122.0625)
280 | ```
281 |
282 | ## Drawing Rectangles
283 |
284 | ```{r, echo=FALSE}
285 | leaflet() %>%
286 | addTiles() %>%
287 | addRectangles(lat1 = 37.3858, lng1 = -122.0595,
288 | lat2 = 37.3890, lng2 = -122.0625)
289 | ```
290 |
291 | ## Adding Legends
292 |
293 | Adding a legend can be useful if you have markers on your
294 | map with different colors:
295 |
296 | ```{r, eval=FALSE}
297 | df <- data.frame(lat = runif(20, min = 39.25, max = 39.35),
298 | lng = runif(20, min = -76.65, max = -76.55),
299 | col = sample(c("red", "blue", "green"), 20, replace = TRUE),
300 | stringsAsFactors = FALSE)
301 |
302 | df %>%
303 | leaflet() %>%
304 | addTiles() %>%
305 | addCircleMarkers(color = df$col) %>%
306 | addLegend(labels = LETTERS[1:3], colors = c("blue", "red", "green"))
307 | ```
308 |
309 | ## Adding Legends
310 |
311 | ```{r, echo=FALSE, message=FALSE}
312 | df <- data.frame(lat = runif(20, min = 39.25, max = 39.35),
313 | lng = runif(20, min = -76.65, max = -76.55),
314 | col = sample(c("red", "blue", "green"), 20, replace = TRUE),
315 | stringsAsFactors = FALSE)
316 |
317 | df %>%
318 | leaflet() %>%
319 | addTiles() %>%
320 | addCircleMarkers(color = df$col) %>%
321 | addLegend(labels = LETTERS[1:3], colors = c("blue", "red", "green"))
322 | ```
323 |
324 | ## Conclusion
325 |
326 | For more details about the leaflet package for R
327 | visit http://rstudio.github.io/leaflet/.
328 |
--------------------------------------------------------------------------------
/leaflet/leaflet.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/leaflet/leaflet.pdf
--------------------------------------------------------------------------------
/plotly/plotly.Rmd:
--------------------------------------------------------------------------------
1 | ---
2 | title: 'plotly'
3 | author: "The Johns Hopkins Data Science Lab"
4 | always_allow_html: yes
5 | ---
6 |
7 | ## What is Plotly?
8 |
9 | Plotly is a web application for creating and sharing data visualizations. Plotly
10 | can work with several programming languages and applications including R,
11 | Python, and Microsoft Excel. We're going to concentrate on creating different
12 | graphs with Plotly and sharing those graphs.
13 |
14 | ## Installing Plotly
15 |
16 | Installing Plotly is easy:
17 |
18 | ```r
19 | install.packages("plotly")
20 | library(plotly)
21 | ```
22 |
23 | If you want to share your visualizations on https://plot.ly/ you should make an
24 | account on their site.
25 |
26 | ## Basic Scatterplot
27 |
28 | A basic scatterplot is easy to make, with the added benefit of tooltips that
29 | appear when your mouse hovers over each point. Specify a scatterplot by
30 | indicating `type = "scatter"`. Notice that the arguments for the `x` and `y`
31 | variables as specified as formulas, with the tilde operator (`~`) preceding the
32 | variable that you're plotting.
33 |
34 |
35 | ```{r, eval=FALSE}
36 | library(plotly)
37 | plot_ly(mtcars, x = ~wt, y = ~mpg, type = "scatter")
38 | ```
39 |
40 | ## Basic Scatterplot
41 |
42 | ```{r, echo=FALSE, message=FALSE}
43 | library(plotly)
44 | plot_ly(mtcars, x = ~wt, y = ~mpg, type = "scatter")
45 | ```
46 |
47 | ## Scatterplot Color
48 |
49 | You can add color to your scatterplot points according to a categorical variable
50 | in the data frame you use with `plot_ly()`.
51 |
52 | ```{r, eval=FALSE}
53 | plot_ly(mtcars, x = ~wt, y = ~mpg, type = "scatter", color = ~factor(cyl))
54 | ```
55 |
56 | ## Scatterplot Color
57 |
58 | ```{r, echo=FALSE, message=FALSE}
59 | plot_ly(mtcars, x = ~wt, y = ~mpg, type = "scatter", color = ~factor(cyl))
60 | ```
61 |
62 | ## Continuous Color
63 |
64 | You can also show continuous variables with color in scatterplots.
65 |
66 | ```{r, eval=FALSE}
67 | plot_ly(mtcars, x = ~wt, y = ~mpg, type = "scatter", color = ~disp)
68 | ```
69 |
70 | ## Continuous Color
71 |
72 | ```{r, echo=FALSE, message=FALSE}
73 | plot_ly(mtcars, x = ~wt, y = ~mpg, type = "scatter", color = ~disp)
74 | ```
75 |
76 | ## Scatterplot Sizing
77 |
78 | By specifying the `size` argument you can make each point in your scatterplot a
79 | different size.
80 |
81 | ```{r, eval=FALSE}
82 | plot_ly(mtcars, x = ~wt, y = ~mpg, type = "scatter",
83 | color = ~factor(cyl), size = ~hp)
84 | ```
85 |
86 | ## Scatterplot Sizing
87 |
88 | ```{r, echo=FALSE, message=FALSE}
89 | plot_ly(mtcars, x = ~wt, y = ~mpg, type = "scatter",
90 | color = ~factor(cyl), size = ~hp)
91 | ```
92 |
93 | ## 3D Scatterplot
94 |
95 | You can create a three-dimensional scatterplot with the `type = "scatter3d"`
96 | argument. If you click and drag these scatterplots you can view them from
97 | different angles.
98 |
99 | ```{r, eval=FALSE}
100 | set.seed(2016-07-21)
101 | temp <- rnorm(100, mean = 30, sd = 5)
102 | pressue <- rnorm(100)
103 | dtime <- 1:100
104 | plot_ly(x = ~temp, y = ~pressue, z = ~dtime,
105 | type = "scatter3d", color = ~temp)
106 | ```
107 |
108 | ## 3D Scatterplot
109 |
110 | ```{r, echo=FALSE, message=FALSE}
111 | set.seed(2016-07-21)
112 | temp <- rnorm(100, mean = 30, sd = 5)
113 | pressue <- rnorm(100)
114 | dtime <- 1:100
115 | plot_ly(x = ~temp, y = ~pressue, z = ~dtime,
116 | type = "scatter3d", color = ~temp)
117 | ```
118 |
119 | ## Line Graph
120 |
121 | Line graphs are the default graph for `plot_ly()`. They're of course useful for
122 | showing change over time:
123 |
124 | ```{r, eval=FALSE}
125 | data("airmiles")
126 | plot_ly(x = ~time(airmiles), y = ~airmiles, type = "scatter", mode = "lines")
127 | ```
128 |
129 | ## Line Graph
130 |
131 | ```{r, echo=FALSE, message=FALSE}
132 | data("airmiles")
133 | plot_ly(x = ~time(airmiles), y = ~airmiles, type = "scatter", mode = "lines")
134 | ```
135 |
136 | ## Multi Line Graph
137 |
138 | You can show multiple lines by specifying the column in the data frame that
139 | separates the lines:
140 |
141 | ```{r, eval=FALSE}
142 | library(plotly)
143 | library(tidyr)
144 | library(dplyr)
145 | data("EuStockMarkets")
146 |
147 | stocks <- as.data.frame(EuStockMarkets) %>%
148 | gather(index, price) %>%
149 | mutate(time = rep(time(EuStockMarkets), 4))
150 |
151 | plot_ly(stocks, x = ~time, y = ~price, color = ~index, type = "scatter", mode = "lines")
152 | ```
153 |
154 | ## Multi Line Graph
155 |
156 | ```{r, echo=FALSE, message=FALSE}
157 | library(plotly)
158 | library(tidyr)
159 | library(dplyr)
160 | data("EuStockMarkets")
161 |
162 | stocks <- as.data.frame(EuStockMarkets) %>%
163 | gather(index, price) %>%
164 | mutate(time = rep(time(EuStockMarkets), 4))
165 |
166 | plot_ly(stocks, x = ~time, y = ~price, color = ~index, type = "scatter", mode = "lines")
167 | ```
168 |
169 | ## Histogram
170 |
171 | A histogram is great for showing how counts of data are distributed. Use the
172 | `type = "histogram"` argument.
173 |
174 | ```{r, eval=FALSE}
175 | plot_ly(x = ~precip, type = "histogram")
176 | ```
177 |
178 | ## Histogram
179 |
180 | ```{r, echo=FALSE, message=FALSE}
181 | plot_ly(x = ~precip, type = "histogram")
182 | ```
183 |
184 | ## Boxplot
185 |
186 | Boxplots are wonderful for comparing how different datasets are distributed.
187 | Specify `type = "box"` to create a boxplot.
188 |
189 | ```{r, eval=FALSE}
190 | plot_ly(iris, y = ~Petal.Length, color = ~Species, type = "box")
191 | ```
192 |
193 | ## Boxplot
194 |
195 | ```{r, echo=FALSE, message=FALSE}
196 | plot_ly(iris, y = ~Petal.Length, color = ~Species, type = "box")
197 | ```
198 |
199 | ## Heatmap
200 |
201 | Heatmaps are useful for displaying three dimensional data in two dimensions,
202 | using color for the third dimension. Create a heatmap by using the
203 | `type = "heatmap"` argument.
204 |
205 | ```{r, eval=FALSE}
206 | terrain1 <- matrix(rnorm(100*100), nrow = 100, ncol = 100)
207 | plot_ly(z = ~terrain1, type = "heatmap")
208 | ```
209 |
210 | ## Heatmap
211 |
212 | ```{r, echo=FALSE, message=FALSE}
213 | terrain1 <- matrix(rnorm(100*100), nrow = 100, ncol = 100)
214 | plot_ly(z = ~terrain1, type = "heatmap")
215 | ```
216 |
217 | ## 3D Surface
218 |
219 | Why limit yourself to two dimensions when you can render three dimensions on a
220 | computer!? Create moveable 3D surfaces with `type = "surface"`.
221 |
222 | ```{r, eval=FALSE}
223 | terrain2 <- matrix(sort(rnorm(100*100)), nrow = 100, ncol = 100)
224 | plot_ly(z = ~terrain2, type = "surface")
225 | ```
226 |
227 | ## 3D Surface
228 |
229 | ```{r, echo=FALSE, message=FALSE}
230 | terrain2 <- matrix(sort(rnorm(100*100)), nrow = 100, ncol = 100)
231 | plot_ly(z = ~terrain2, type = "surface")
232 | ```
233 |
234 | ## Choropleth Maps: Setup
235 |
236 | Choropleth maps illustrate data across geographic areas by shading regions with
237 | different colors. Choropleth maps are easy to make with Plotly though they
238 | require more setup compared to other Plotly graphics.
239 |
240 | ```{r, eval=FALSE}
241 | # Create data frame
242 | state_pop <- data.frame(State = state.abb, Pop = as.vector(state.x77[,1]))
243 | # Create hover text
244 | state_pop$hover <- with(state_pop, paste(State, '
', "Population:", Pop))
245 | # Make state borders white
246 | borders <- list(color = toRGB("red"))
247 | # Set up some mapping options
248 | map_options <- list(
249 | scope = 'usa',
250 | projection = list(type = 'albers usa'),
251 | showlakes = TRUE,
252 | lakecolor = toRGB('white')
253 | )
254 | ```
255 |
256 | ## Choropleth Maps: Mapping
257 |
258 | ```{r, eval=FALSE}
259 | plot_ly(z = ~state_pop$Pop, text = ~state_pop$hover, locations = ~state_pop$State,
260 | type = 'choropleth', locationmode = 'USA-states',
261 | color = state_pop$Pop, colors = 'Blues', marker = list(line = borders)) %>%
262 | layout(title = 'US Population in 1975', geo = map_options)
263 | ```
264 |
265 | ## Choropleth Maps
266 |
267 | ```{r, echo=FALSE, message=FALSE}
268 | # Create data frame
269 | state_pop <- data.frame(State = state.abb, Pop = as.vector(state.x77[,1]))
270 | # Create hover text
271 | state_pop$hover <- with(state_pop, paste(State, '
', "Population:", Pop))
272 | # Make state borders white
273 | borders <- list(color = toRGB("red"))
274 | # Set up some mapping options
275 | map_options <- list(
276 | scope = 'usa',
277 | projection = list(type = 'albers usa'),
278 | showlakes = TRUE,
279 | lakecolor = toRGB('white')
280 | )
281 |
282 | plot_ly(z = ~state_pop$Pop, text = ~state_pop$hover, locations = ~state_pop$State,
283 | type = 'choropleth', locationmode = 'USA-states',
284 | color = state_pop$Pop, colors = 'Blues', marker = list(line = borders)) %>%
285 | layout(title = 'US Population in 1975', geo = map_options)
286 | ```
287 |
288 | ## More Resources
289 |
290 | - [The Plolty Website](https://plot.ly/)
291 | - [The Plotly R API](https://plot.ly/r/)
292 | - [The Plotly R Package on GitHub](https://github.com/ropensci/plotly)
293 | - [The Plotly R Cheatsheet](https://images.plot.ly/plotly-documentation/images/r_cheat_sheet.pdf)
294 | - ["Plotly for R" book by Carson Sievert](https://cpsievert.github.io/plotly_book/)
--------------------------------------------------------------------------------
/plotly/plotly.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/plotly/plotly.pdf
--------------------------------------------------------------------------------
/sharingrmd.Rmd:
--------------------------------------------------------------------------------
1 | ---
2 | ---
3 |
4 | # [Developing Data Products](index.html)
5 |
6 | ## Sharing R Markdown Documents
7 |
8 | We recommend the following websites for sharing the HTML files that you produce
9 | from R Markdown documents. If you've taken The Data Scientist's Toolbox then
10 | you should be familiar with [GitHub Pages](https://pages.github.com/).
11 | If you're familiar with Git and you haven't used it before their documentation
12 | for creating a site is very straightforward. If you're not familiar with Git
13 | and you're using RStudio you should take advantage of
14 | [RPubs](http://rpubs.com/), which is perhaps the easiest way to share an HTML
15 | document from RStudio. You can find simple instructions for using RPubs
16 | [here](http://rpubs.com/about/getting-started). If you're looking for a site
17 | that will host any HTML file for free, including HTML files that are generated
18 | by R Markdown, you should check out [NeoCities](https://neocities.org/). You'll
19 | need to provide links to HTML files you've created with R Makrdown in upcoming
20 | peer assessments, so make sure to familiarize yourself with one of these sites.
21 |
22 | ---
23 |
24 | [**Back to Developing Data Products Home**](index.html)
--------------------------------------------------------------------------------
/sharingrmd.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/sharingrmd.pdf
--------------------------------------------------------------------------------
/shiny.Rmd:
--------------------------------------------------------------------------------
1 | ---
2 | ---
3 |
4 | # [Developing Data Products](index.html)
5 |
6 | Remember to read the book chapters on Shiny.
7 |
8 | Shiny is an important enough topic to devote a lot of time to it. Shiny is another product by RStudio and it is described by RStudio as “A web application framework for R”. They further add “Turn your analyses into interactive web applications No HTML, CSS, or JavaScript knowledge required”. This is mostly true, though a little HTML at least would be useful for understanding some of the concepts. Here’s a useful site for learning html basics. We’ll proceed as if your html knowledge is very basic and no more advanced than understanding heading levels for fonts. It is important to distinguish between a Shiny applications (app) and a Shiny server. A Shiny server is required to host a shiny app for the world. Otherwise, only those who have shiny installed and have access to your code could run your web page (really defeating the purpose of making a web page in the first place).
9 |
10 | In this class, we won’t cover creating a shiny server, as that requires understanding a little Linux server administration. Instead, we’ll run our apps locally and use RStudio’s service for hosting shiny apps (their servers) on a platform called shinyapps.io. In other words, RStudio does the server work for your so that all you need to worry about is building your app. Shinyapps.io is free up to a point in that you can only run 5 apps for a certain amount of time per month. This will be fine for our purposes, but if you’re really going to get into making Shiny apps, you’ll have to spring for a paid plan or run your own server.
11 |
12 | ---
13 |
14 | [**Back to Developing Data Products Home**](index.html)
--------------------------------------------------------------------------------
/shiny.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/shiny.pdf
--------------------------------------------------------------------------------
/shinyproject.Rmd:
--------------------------------------------------------------------------------
1 | ---
2 | ---
3 |
4 | # [Developing Data Products](index.html)
5 |
6 | Some people in this session let us know that they are concerned about running up against the 25-hour per month limit on the free tier of shinyapps.io.
7 |
8 | Should you hit the limit on the free plan, RStudio will send you a message. If you receive the message and are more than a few days from getting a fresh 25 hours on your monthly renewal, please send an email to shinyapps-support@rstudio.com with the email address you use on the service and the account name you are using (the first part of the URL). RStudio will then increase your limit so you can continue working on your project.
9 |
10 | Since there are a lot of folks in the class we'd appreciate if you only emailed RStudio after you get the message and only if you feel you'll need more time.
11 |
12 | ---
13 |
14 | [**Back to Developing Data Products Home**](index.html)
--------------------------------------------------------------------------------
/shinyproject.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/shinyproject.pdf
--------------------------------------------------------------------------------
/slides.css:
--------------------------------------------------------------------------------
1 | img {
2 | height: 400px;
3 | width: auto;
4 | }
--------------------------------------------------------------------------------
/swirl/swirl.Rmd:
--------------------------------------------------------------------------------
1 | ---
2 | title: 'swirl'
3 | author: "The Johns Hopkins Data Science Lab"
4 | always_allow_html: yes
5 | ---
6 |
7 | ## What is swirl? Part 1
8 |
9 | - Swirl is an R package that turns the R console into an interactive learning
10 | evironment.
11 | - Students are guided through R programming exercises where they
12 | can answer questions in the R console.
13 | - There is no separation between where a student learns to use R, and where
14 | they go on to use R for thier own creative purposes.
15 |
16 | If you've never used swirl before you shoud try swirl out for yourself:
17 |
18 | ```r
19 | install.packages("swirl")
20 | library(swirl)
21 | swirl()
22 | ```
23 |
24 | ## What is swirl? Part 2
25 |
26 | - Anyone can create and distribute their own swirl course!
27 | - Creating a swirl course can allow you scale R and data science education
28 | within your company or school.
29 | - If you're interested in getting involved in the open source education
30 | community you can release your swirl course online and Team swirl will promote
31 | it for you!
32 | - There's a package called swirlify which is designed to help you write a swirl
33 | course. We'll look into swirlify later.
34 |
35 | ## What is a swirl course?
36 |
37 | - A swirl course is a directory that contains all of the files, folders, and
38 | lessons associated with the course you are developing.
39 | - Lessons contain most of the content that students interact with, and the
40 | course sequentially organizes these lessons.
41 | - A course should conceptually encapsulate a broad concept that you want to
42 | teach. For example: “Plotting in R” or “Statistics for Engineers” are broad
43 | enough topics that they could be broken down further (into lessons which we’ll
44 | talk about next).
45 | - When a student start swirl, they will prompted to choose from a list of
46 | courses, and then they can choose a lesson within the course they selected.
47 | - Once the student selects a lesson, swirl will start asking the student
48 | questions in the R console.
49 |
50 | ## What is a lesson?
51 |
52 | - A lesson is a directory that contains all of the files required to execute one
53 | unit of instruction inside of swirl.
54 | - For example a "Plotting in R" course might contain the lessons: "Plotting
55 | with Base Graphics", "Plotting with Lattice", and "Plotting with ggplot2."
56 | - Every lesson must contain one `lesson.yaml`
57 | file which structures the text that the student will see inside the R console
58 | while they are using swirl.
59 | - The `lesson.yaml` file contains a sequence of questions that students will
60 | be prompted with.
61 |
62 | ## Writing swirl Courses: Setting up the App
63 |
64 | First install swirlify:
65 |
66 | ```r
67 | install.packages("swirlify")
68 | library(swirlify)
69 | ```
70 |
71 | Then set your working directory to wherever you want to create your course and
72 | start the Shiny lesson authoring app:
73 |
74 | ```r
75 | setwd(file.path("~", "Desktop"))
76 | swirlify("Lesson 1", "My First Course")
77 | ```
78 |
79 | ## Writing swirl Courses: Using the App
80 |
81 | For a demo about how to use the Shiny authoring app see the following video:
82 | https://youtu.be/UPL_W-Umgjs
83 |
84 | ## Writing swirl Courses: Using the R Console
85 |
86 | - Alternatively you can use the R console and a text editor to write swirl
87 | lessons.
88 | - We highly recommend using
89 | [RStudio](https://www.rstudio.com/products/rstudio/download/)
90 | for writing swirl lessons since RStudio provides this editor and console setup
91 | by default.
92 |
93 | To start a new lesson from the R console set your working directory to where
94 | you want to create the course, and then use the `new_lesson()` function to
95 | create the course:
96 |
97 | ```r
98 | setwd("/Users/sean/")
99 | new_lesson("My First Lesson", "My First Course")
100 | ```
101 |
102 | ## Writing Lessons: Part 1
103 |
104 | The `new_lesson()` function will create a file and folder structure like this
105 | in your working directory:
106 |
107 | ```r
108 | My_New_Course
109 | - My_First_Lesson
110 | - lesson.yaml
111 | - initLesson.R
112 | - dependson.txt
113 | - customTests.R
114 | ```
115 |
116 | ## Writing Lessons: Part 2
117 |
118 | To review, the `new_lesson()` function did the following:
119 |
120 | 1. A new directory was created in `/Users/sean/` called `My_New_Course`.
121 | 2. A new directory was created in `/Users/sean/My_New_Course` called `My_First_Lesson`.
122 |
123 | ## Writing Lessons: Part 2.5
124 |
125 | - Several files were created inside of `/Users/sean/My_New_Course/My_First_Lesson`:
126 | - `lesson.yaml` is where you will write all of the questions for this lesson. ([Example](https://github.com/seankross/Test_Course/blob/master/Test_Lesson/lesson.yaml))
127 | - `initLesson.R` is an R script that is run before the lesson starts which is
128 | usually used to load data or set up environmental variables. ([Example](https://github.com/seankross/Test_Course/blob/master/Test_Lesson/initLesson.R))
129 | - `dependson.txt` is the list of R packages your lesson will require. swirl
130 | will install these packages if the user doesn't already have them installed. ([Example](https://github.com/seankross/Test_Course/blob/master/Test_Lesson/dependson.txt))
131 | - `customTests.R` is where you can write your own tests for student's answers.
132 | ([Example](https://github.com/seankross/Test_Course/blob/master/Test_Lesson/customTests.R))
133 |
134 | ## Writing Lessons: Part 3
135 |
136 | If everything is set up correctly then `new_lesson()` should have opened up the
137 | new `lesson.yaml` file in a text editor. You can now start adding questions to
138 | the `lesson.yaml` by using functions that start with `wq_` (write question).
139 |
140 | ## Writing Lessons: Types of Questions
141 |
142 | Lessons are sequences of questions that have the following general structure:
143 |
144 | ```
145 | - Class: [type of question]
146 | Key1: [value1]
147 | Key2: [value2]
148 |
149 | - Class: [type of question]
150 | Key1: [value1]
151 | Key2: [value2]
152 | ...
153 | ```
154 |
155 | The example above shows the high-level structure for two questions.
156 |
157 | ## Writing Lessons: Types of Questions
158 |
159 | - Each question is demarcated with a hyphen.
160 | - Every question starts with a `Class` that specifies that question's behavior
161 | inside of swirl.
162 | - What follows the class is a set of key-value pairs that will be used to render
163 | the question when a student is using swirl.
164 |
165 | ## Writing Lessons: The Meta Question
166 |
167 | The first question in every `lesson.yaml` is always the meta question which
168 | contains general information about the course. Below is an example of the meta
169 | question:
170 |
171 | ```
172 | - Class: meta
173 | Course: My Course
174 | Lesson: My Lesson
175 | Author: Dr. Jennifer Bryan
176 | Type: Standard
177 | Organization: The University of British Columbia
178 | Version: 2.5
179 | ```
180 | The meta question will not be displayed to a student. The only fields you should
181 | modify are `Author` and `Organization` fields.
182 |
183 | ## Writing Lessons: Message Questions
184 |
185 | Message questions display a string of text in the R console for the student to
186 | read. Once the student presses enter, swirl will move on to the next question.
187 |
188 | Add a message question using `wq_message()`.
189 |
190 | Here's an example message question:
191 |
192 | ```
193 | - Class: text
194 | Output: Welcome to my first swirl course!
195 | ```
196 |
197 | The student will see the following in the R console:
198 |
199 | ```
200 | | Welcome to my first swirl course!
201 |
202 | ...
203 | ```
204 |
205 | ## Writing Lessons: Command Questions
206 |
207 | Command questions prompt the student to type an expression into the R console.
208 |
209 | - The `CorrectAnswer` is entered into the console if the student uses the `skip()`
210 | function.
211 | - The `Hint` is displayed to the student if they don't get the question right.
212 | - The `AnswerTests` determine whether or not the student answered the question
213 | correctly. See the answer testing section for more information.
214 |
215 | Add a message question using `wq_command()`.
216 |
217 | ## Writing Lessons: Command Questions
218 |
219 | Here's an example command question:
220 |
221 | ```
222 | - Class: cmd_question
223 | Output: Add 2 and 2 together using the addition operator.
224 | CorrectAnswer: 2 + 2
225 | AnswerTests: omnitest(correctExpr='2 + 2')
226 | Hint: Just type 2 + 2.
227 | ```
228 |
229 | The student will see the following in the R console:
230 |
231 | ```
232 | | Add 2 and 2 together using the addition operator.
233 |
234 | >
235 | ```
236 |
237 | ## Multiple Choice Questions
238 |
239 | Multiple choice questions present a selection of options to the student. These
240 | options are presented in a different order every time the question is seen.
241 |
242 | - The `AnswerChoices` should be a semicolon separated string of choices that
243 | the student will have to choose from.
244 |
245 | Add a message question using `wq_multiple()`.
246 |
247 | Here's an example multiple choice question:
248 |
249 | ```
250 | - Class: mult_question
251 | Output: What is the capital of Canada?
252 | AnswerChoices: Toronto;Montreal;Ottawa;Vancouver
253 | CorrectAnswer: Ottawa
254 | AnswerTests: omnitest(correctVal='Ottawa')
255 | Hint: This city contains the Rideau Canal.
256 | ```
257 |
258 | ## Multiple Choice Questions
259 |
260 | The student will see the following in the R console:
261 |
262 | ```
263 | | What is the capital of Canada?
264 |
265 | 1: Toronto
266 | 2: Montreal
267 | 3: Ottawa
268 | 4: Vancouver
269 | ```
270 |
271 | ## Other Question Types
272 |
273 | For complete documentation about writing swirl courses and lessons see the
274 | swirlify website: http://swirlstats.com/swirlify/
275 |
276 | ## Organizing Lessons: Part 1
277 |
278 | Let's revisit the general structure of a swirl course. This is the structure of
279 | a course with two lessons:
280 |
281 | ```
282 | My_New_Course
283 | - My_First_Lesson
284 | - lesson.yaml
285 | - initLesson.R
286 | - dependson.txt
287 | - customTests.R
288 | - My_Second_Lesson
289 | - lesson.yaml
290 | - initLesson.R
291 | - dependson.txt
292 | - customTests.R
293 | ```
294 |
295 | ## Organizing Lessons: Part 2
296 |
297 | - By default each folder in `My_New_Course` will be displayed to the student
298 | as a lesson they can select.
299 | - If you want to explicitly specify the order in which lessons are displayed
300 | you will need to add a `MANIFEST` file to your course.
301 | - You can do this with the `add_to_manifest()` function, which will add
302 | the lesson you are currently working on to the `MANIFEST`. You can also edit
303 | the `MANIFEST` yourself in a text editor.
304 |
305 | ## Organizing Lessons: Part 3
306 |
307 | The (abridged) `MANIFEST` file below belongs to Team swirl's
308 | R Programming course:
309 |
310 | ```
311 | Basic_Building_Blocks
312 | Workspace_and_Files
313 | Sequences_of_Numbers
314 | Vectors
315 | Missing_Values
316 | Subsetting_Vectors
317 | Matrices_and_Data_Frames
318 | ```
319 |
320 | ## Sharing Your Course
321 |
322 | Swirlify makes sharing a swirl course easy. We recommend three different methods
323 | for sharing a swirl course.
324 |
325 | ## Sharing Your Course as a File
326 |
327 | We've developed the `.swc` file type so that you can share your course as a
328 | single file. Creating an `.swc` file for your course is easy:
329 |
330 | 1. Set any lesson in the course you want to share as the current lesson using
331 | `set_lesson()`.
332 | 2. Create an `.swc` file using the `pack_course()` function. Your `.swc` file
333 | will appear in the same directory as the directory that contains the course
334 | folder. You also have the option to export the `.swc` file to another directory
335 | by specifying the `export_path` argument.
336 |
337 | ## Sharing Your Course as a File
338 |
339 | - You can now share your `.swc` file like you would any other file (through email, file sharing services, etc).
340 | - Students can install your course from the `.swc` file by downloading the
341 | file and then using the `install_course()` function in swirl, which will
342 | prompt them to interactively select the file they downloaded.
343 |
344 | ## Sharing Your Course on GitHub
345 |
346 | - We highly encourage you to develop your course on
347 | [GitHub](https://github.com/) so that we can better support you if you
348 | have questions or need assistance while developing your course.
349 | - Developing your course on GitHub provides the added
350 | benefit that your course will be instantly ready to distribute.
351 | - Students can install your course from swirl using the `install_course_github()` function.
352 | - Make sure that your course directory is the root folder of your
353 | git repository. For examples of courses that have been shared on GitHub
354 | you can browse some of the courses on
355 | the [Swirl Course Network](http://swirlstats.com/scn/).
356 |
357 | ## Sharing Your Course on The Swirl Course Network
358 |
359 | The goal of the Swirl Course Network is to list and organize all publicly
360 | available swirl courses. Visit the [homepage](http://swirlstats.com/scn/) of the
361 | SCN for more information.
362 |
363 | After adding your course to the SCN students will be able to install your course
364 | using `install_course("[Name of Your Course]")` in swirl.
365 |
366 | ## Sharing Your Course on The Swirl Course Network
367 |
368 | In order to add your course to the SCN:
369 |
370 | 1. Create an `.swc` file for your course.
371 | 2. Fork https://github.com/swirldev/scn on GitHub.
372 | 3. Add the `.swc` file to your fork.
373 | 4. Add an Rmd file to your fork like
374 | [this one](https://raw.githubusercontent.com/swirldev/scn/gh-pages/rprog.Rmd).
375 | You can include a description of your course, authors, a course website, and
376 | how to install your course.
377 | 5. Run `rmarkdown::render_site()` when your current directory is set to your
378 | fork.
379 | 6. Add, commit, and push your changes to GitHub, then send us a Pull Request.
380 |
381 | ## More Help & Resources
382 |
383 | - [The swirl Website](http://swirlstats.com/)
384 | - [The swirlify Documentation](http://swirlstats.com/swirlify/)
385 | - [The swirl Course Network](http://swirlstats.com/scn/)
386 |
387 | Feel free to get in touch with Team swirl:
388 |
389 | - Via email: info@swirlstats.com
390 | - On Twitter: @[swirlstats](https://twitter.com/swirlstats)
--------------------------------------------------------------------------------
/swirl/swirl.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/swirl/swirl.pdf
--------------------------------------------------------------------------------
/syllabus.Rmd:
--------------------------------------------------------------------------------
1 | ---
2 | ---
3 |
4 | # [Developing Data Products](index.html)
5 |
6 | ## Course Title
7 |
8 | Developing Data Products
9 |
10 | ## Course Instructor(s)
11 |
12 | The primary instructor of this class is [Brian Caffo](http://www.bcaffo.com/)
13 |
14 | Brian is a professor at Johns Hopkins Biostatistics and co-directs the [SMART working group](http://www.smart-stats.org/)
15 |
16 | This class is co-taught by Roger Peng and Jeff Leek.
17 |
18 | ## Course Description
19 |
20 | A data product is the production output from a statistical analysis. Data products automate complex analysis tasks or use technology to expand the utility of a data informed model, algorithm or inference. This course covers the basics of creating data products using Shiny, R packages, and interactive graphics. The course will focus on the fundamentals of creating a data product that can be used to tell a story about data to a mass audience.
21 |
22 | In this class students will learn a variety of core tools for creating data products in R and R Studio in specific. Students will be evaluated via quizzes and a culminating project.
23 |
24 | Course Content
25 |
26 | The lectures will be taught over four weeks with the third week dedicated to creating R packages.
27 |
28 | The weeks are organized as follows
29 |
30 | 1. Shiny, rCharts, manipulate, googleVis
31 | 2. Presenting data analysis, slidify, R Studio presenter.
32 | 3. Students creating and deploying their projects
33 | 4. Creating R packages, classes and methods, yhat.
34 |
35 | ## Github repository
36 |
37 | The most up to date information on the course lecture notes will always be in the Github repository
38 |
39 | The data science specialization is here
40 |
41 | https://github.com/DataScienceSpecialization/Developing_Data_Products
42 |
43 | Please issue pull requests so that we may improve the materials.
44 |
45 | ## YouTube
46 |
47 | If you'd prefer to watch the videos on YouTube, most of them can be found here:
48 |
49 | https://www.youtube.com/playlist?list=PLpl-gQkQivXhr9PyOWSA3aOHf4ZNTrs90
50 |
51 | ## Book: Developing Data Products in R
52 |
53 | This book introduces the topic of Developing Data Products in R. A data product is the ideal output of a Data Science experiment. This book is based on the Coursera Class "Developing Data Products" as part of the Data Science Specialization. Particular emphasis is paid to developing Shiny apps and interactive graphics.
54 |
55 | The book is available here: https://leanpub.com/ddp
56 |
57 | It's variable pricing, including free! It also includes some content (like leaflet) that was not covered in the class and omits some other. It's a little rough, but as I work on it you'll get all of the updates.
58 |
59 | ## Weekly quizzes
60 |
61 | - There are three weekly quizzes.
62 | - You must earn a grade of at least 80% to pass a quiz
63 | - You may attempt each quiz up to 3 times in 8 hours.
64 | - The score from your most successful attempt will count toward your final grade.
65 |
66 | ## Course Project
67 |
68 | The Course Project is an opportunity to demonstrate the skills you have learned during the course. It is graded through peer assessment. You must earn a grade of at least 80% to pass the course project.
69 |
70 | ## Grading policy
71 |
72 | You must score at least 80% on all assignments (Quizzes & Project) to pass the course.
73 |
74 | Your final grade will be calculated as follows:
75 |
76 | - Quiz 1 = 20%
77 | - Quiz 2 = 20%
78 | - Quiz 3 = 20%
79 | - Course project = 40%
80 |
81 | ## Differences of opinion
82 |
83 | Keep in mind that currently data analysis is as much art as it is science - so we may have a difference of opinion - and that is ok! Please refrain from angry, sarcastic, or abusive comments on the message boards. Our goal is to create a supportive community that helps the learning of all students, from the most advanced to those who are just seeing this material for the first time.
84 |
85 | ## Plagiarism
86 |
87 | Johns Hopkins University defines plagiarism as "...taking for one's own use the words, ideas, concepts or data of another without proper attribution. Plagiarism includes both direct use or paraphrasing of the words, thoughts, or concepts of another without proper attribution." We take plagiarism very seriously, as does Johns Hopkins University.
88 |
89 | We recognize that many students may not have a clear understanding of what plagiarism is or why it is wrong. Please see the JHU referencing guide for more information on plagiarism.
90 |
91 | It is critically important that you give people/sources credit when you use their words or ideas. If you do not give proper credit -- particularly when quoting directly from a source -- you violate the trust of your fellow students.
92 |
93 | The Coursera Honor code includes an explicit statement about plagiarism:
94 |
95 | I will register for only one account. My answers to homework, quizzes and exams will be my own work (except for assignments that explicitly permit collaboration). I will not make solutions to homework, quizzes or exams available to anyone else. This includes both solutions written by me, as well as any official solutions provided by the course staff. I will not engage in any other activities that will dishonestly improve my results or dishonestly improve/hurt the results of others.
96 |
97 | ### Reporting plagiarism on course projects
98 |
99 | One of the criteria in the project rubric focuses on plagiarism. Keep in mind that some components of the projects will be very similar across terms and so answers that appear similar may be honest coincidences. However, we would appreciate if you do a basic check for obvious plagiarism and report it during your peer assessment phase.
100 |
101 | It is currently very difficult to prove or disprove a charge of plagiarism in the MOOC peer assessment setting. We are not in a position to evaluate whether or not a submission actually constitutes plagiarism, and we will not be able to entertain appeals or to alter any grades that have been assigned through the peer evaluation system.
102 |
103 | But if you take the time to report suspected plagiarism, this will help us to understand the extent of the problem and work with Coursera to address critical issues with the current system.
104 |
105 | ---
106 |
107 | [*Back to Developing Data Products Home*](index.html)
--------------------------------------------------------------------------------
/syllabus.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/syllabus.pdf
--------------------------------------------------------------------------------
/welcome.Rmd:
--------------------------------------------------------------------------------
1 | ---
2 | ---
3 |
4 | # [Developing Data Products](index.html)
5 |
6 | ## Welcome
7 |
8 | I'm glad that you decided to take Developing Data Products,
9 | part of the [Data Science Specialization](https://www.coursera.org/specializations/jhu-data-science/)
10 | from Johns Hopkins Biostatistics!
11 |
12 | A data product is the production output from a statistical
13 | analysis. Data products automate complex analysis tasks or
14 | use technology to expand the utility of a data informed
15 | model, algorithm or inference. This course covers the basics
16 | of creating data products using Shiny, R packages, and
17 | interactive graphics. This course focuses on the statistical
18 | fundamentals of creating a data product that can be used to
19 | tell a story about data to a mass audience.
20 |
21 | You will learn how to communicate using statistics and
22 | statistical products. Emphasis will be paid to communicating
23 | uncertainty in statistical results. You will learn how to
24 | create simple Shiny web applications and R packages for
25 | their data products. In addition, we'll cover reproducible
26 | presentations and interactive graphics.
27 |
28 | We believe that the key word in Data Science is "science".
29 | Our specialization is focused on providing you with three
30 | things: (1) an introduction to the key ideas behind working
31 | with data in a scientific way that will produce new and
32 | reproducible insight, (2) an introduction to the tools that
33 | will allow you to execute on a data analytic strategy, from
34 | raw data in a database to a completed report with
35 | interactive graphics, and (3) on giving you plenty of hands
36 | on practice so you can learn the techniques for yourself.
37 | This course represents the final cog in a data science
38 | application, creating an end-usable data product.
39 |
40 | We are excited about the opportunity to attempt to scale
41 | Data Science education. We intend for the courses to be
42 | self-contained, fast-paced, and interactive.
43 |
44 | ## Some Basics
45 |
46 | A couple of first week housekeeping items. First, make sure
47 | that you've had R Programming and the Data Scientist's
48 | Toolbox. Reproducible Research would be helpful, but is not
49 | mandatory. At a minimum you must know: very basic git, basic
50 | R and very basic knitr.
51 |
52 | An important aspect of this class is to peruse the materials
53 | in the github repository. All of the most up to date
54 | material can be found here:
55 | https://github.com/DataScienceSpecialization/Developing_Data_Products
56 |
57 | You should clone this repository as your first step in this
58 | class and make sure to fetch updates periodically. (Please
59 | send pull requests too!) It is one of the most essential
60 | components of the Specialization that you start to use Git
61 | frequently. We're practicing what we preach as well by using
62 | the tools in the series to create the series, especially git.
63 |
64 | You can clone the whole repo with (http)
65 |
66 | - `git clone https://github.com/DataScienceSpecialization/Developing_Data_Products.git`
67 | - or `(ssh)`
68 | - `git clone git@github.com:DataScienceSpecialization/Developing_Data_Products.git`
69 |
70 | The lectures are in the index.Rmd lecture files. In this
71 | class, we'll cover how to create these sorts of slides. You
72 | will see all of the R code to recreate the lectures. Going
73 | through the R code is the best way to familiarize yourself
74 | with the lecture materials.
75 |
76 | **The lecture material for this class is largely front-loaded.
77 | This is because the latter time of the class is devoted to
78 | developing your data application.** Thus the class should be
79 | doable in about a month's time or maybe less. Though make
80 | sure you're keeping up with the classes at the beginning so
81 | that you have some space in your schedule later on for app
82 | development!
83 |
84 | If you'd like to keep up with the instructors I'm
85 | [\@bcaffo](http://twitter.com/bcaffo)
86 | on twitter, Roger is [\@rdpeng](http://twitter.com/rdpeng) and
87 | Jeff is [\@jtleek](http://twitter.com/jtleek). The
88 | Department of Biostat here is
89 | [\@jhubiostat](http://twitter.com/jhubiostat).
90 |
91 | ---
92 |
93 | [**Back to Developing Data Products Home**](index.html)
--------------------------------------------------------------------------------
/welcome.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataScienceSpecialization/Developing_Data_Products/32dc80f5a9dbfca9bcf49378fb1c5e8adb2d57d8/welcome.pdf
--------------------------------------------------------------------------------