").addClass(errClass).css("position", "absolute")
331 | .css("top", el.offsetTop)
332 | .css("left", el.offsetLeft)
333 | // setting width can push out the page size, forcing otherwise
334 | // unnecessary scrollbars to appear and making it impossible for
335 | // the element to shrink; so use max-width instead
336 | .css("maxWidth", el.offsetWidth)
337 | .css("height", el.offsetHeight);
338 | errorDiv.text(err.message);
339 | $el.after(errorDiv);
340 |
341 | // Really dumb way to keep the size/position of the error in sync with
342 | // the parent element as the window is resized or whatever.
343 | var intId = setInterval(function() {
344 | if (!errorDiv[0].parentElement) {
345 | clearInterval(intId);
346 | return;
347 | }
348 | errorDiv
349 | .css("top", el.offsetTop)
350 | .css("left", el.offsetLeft)
351 | .css("maxWidth", el.offsetWidth)
352 | .css("height", el.offsetHeight);
353 | }, 500);
354 | }
355 | }
356 | },
357 | clearError: function(el) {
358 | var $el = $(el);
359 | var display = $el.data("restore-display-mode");
360 | $el.data("restore-display-mode", null);
361 |
362 | if (display === "inline" || display === "inline-block") {
363 | if (display)
364 | $el.css("display", display);
365 | $(el.nextSibling).filter(".htmlwidgets-error").remove();
366 | } else if (display === "block"){
367 | $el.css("visibility", "inherit");
368 | $(el.nextSibling).filter(".htmlwidgets-error").remove();
369 | }
370 | },
371 | sizing: {}
372 | };
373 |
374 | // Called by widget bindings to register a new type of widget. The definition
375 | // object can contain the following properties:
376 | // - name (required) - A string indicating the binding name, which will be
377 | // used by default as the CSS classname to look for.
378 | // - initialize (optional) - A function(el) that will be called once per
379 | // widget element; if a value is returned, it will be passed as the third
380 | // value to renderValue.
381 | // - renderValue (required) - A function(el, data, initValue) that will be
382 | // called with data. Static contexts will cause this to be called once per
383 | // element; Shiny apps will cause this to be called multiple times per
384 | // element, as the data changes.
385 | window.HTMLWidgets.widget = function(definition) {
386 | if (!definition.name) {
387 | throw new Error("Widget must have a name");
388 | }
389 | if (!definition.type) {
390 | throw new Error("Widget must have a type");
391 | }
392 | // Currently we only support output widgets
393 | if (definition.type !== "output") {
394 | throw new Error("Unrecognized widget type '" + definition.type + "'");
395 | }
396 | // TODO: Verify that .name is a valid CSS classname
397 |
398 | // Support new-style instance-bound definitions. Old-style class-bound
399 | // definitions have one widget "object" per widget per type/class of
400 | // widget; the renderValue and resize methods on such widget objects
401 | // take el and instance arguments, because the widget object can't
402 | // store them. New-style instance-bound definitions have one widget
403 | // object per widget instance; the definition that's passed in doesn't
404 | // provide renderValue or resize methods at all, just the single method
405 | // factory(el, width, height)
406 | // which returns an object that has renderValue(x) and resize(w, h).
407 | // This enables a far more natural programming style for the widget
408 | // author, who can store per-instance state using either OO-style
409 | // instance fields or functional-style closure variables (I guess this
410 | // is in contrast to what can only be called C-style pseudo-OO which is
411 | // what we required before).
412 | if (definition.factory) {
413 | definition = createLegacyDefinitionAdapter(definition);
414 | }
415 |
416 | if (!definition.renderValue) {
417 | throw new Error("Widget must have a renderValue function");
418 | }
419 |
420 | // For static rendering (non-Shiny), use a simple widget registration
421 | // scheme. We also use this scheme for Shiny apps/documents that also
422 | // contain static widgets.
423 | window.HTMLWidgets.widgets = window.HTMLWidgets.widgets || [];
424 | // Merge defaults into the definition; don't mutate the original definition.
425 | var staticBinding = extend({}, defaults, definition);
426 | overrideMethod(staticBinding, "find", function(superfunc) {
427 | return function(scope) {
428 | var results = superfunc(scope);
429 | // Filter out Shiny outputs, we only want the static kind
430 | return filterByClass(results, "html-widget-output", false);
431 | };
432 | });
433 | window.HTMLWidgets.widgets.push(staticBinding);
434 |
435 | if (shinyMode) {
436 | // Shiny is running. Register the definition with an output binding.
437 | // The definition itself will not be the output binding, instead
438 | // we will make an output binding object that delegates to the
439 | // definition. This is because we foolishly used the same method
440 | // name (renderValue) for htmlwidgets definition and Shiny bindings
441 | // but they actually have quite different semantics (the Shiny
442 | // bindings receive data that includes lots of metadata that it
443 | // strips off before calling htmlwidgets renderValue). We can't
444 | // just ignore the difference because in some widgets it's helpful
445 | // to call this.renderValue() from inside of resize(), and if
446 | // we're not delegating, then that call will go to the Shiny
447 | // version instead of the htmlwidgets version.
448 |
449 | // Merge defaults with definition, without mutating either.
450 | var bindingDef = extend({}, defaults, definition);
451 |
452 | // This object will be our actual Shiny binding.
453 | var shinyBinding = new Shiny.OutputBinding();
454 |
455 | // With a few exceptions, we'll want to simply use the bindingDef's
456 | // version of methods if they are available, otherwise fall back to
457 | // Shiny's defaults. NOTE: If Shiny's output bindings gain additional
458 | // methods in the future, and we want them to be overrideable by
459 | // HTMLWidget binding definitions, then we'll need to add them to this
460 | // list.
461 | delegateMethod(shinyBinding, bindingDef, "getId");
462 | delegateMethod(shinyBinding, bindingDef, "onValueChange");
463 | delegateMethod(shinyBinding, bindingDef, "onValueError");
464 | delegateMethod(shinyBinding, bindingDef, "renderError");
465 | delegateMethod(shinyBinding, bindingDef, "clearError");
466 | delegateMethod(shinyBinding, bindingDef, "showProgress");
467 |
468 | // The find, renderValue, and resize are handled differently, because we
469 | // want to actually decorate the behavior of the bindingDef methods.
470 |
471 | shinyBinding.find = function(scope) {
472 | var results = bindingDef.find(scope);
473 |
474 | // Only return elements that are Shiny outputs, not static ones
475 | var dynamicResults = results.filter(".html-widget-output");
476 |
477 | // It's possible that whatever caused Shiny to think there might be
478 | // new dynamic outputs, also caused there to be new static outputs.
479 | // Since there might be lots of different htmlwidgets bindings, we
480 | // schedule execution for later--no need to staticRender multiple
481 | // times.
482 | if (results.length !== dynamicResults.length)
483 | scheduleStaticRender();
484 |
485 | return dynamicResults;
486 | };
487 |
488 | // Wrap renderValue to handle initialization, which unfortunately isn't
489 | // supported natively by Shiny at the time of this writing.
490 |
491 | shinyBinding.renderValue = function(el, data) {
492 | Shiny.renderDependencies(data.deps);
493 | // Resolve strings marked as javascript literals to objects
494 | if (!(data.evals instanceof Array)) data.evals = [data.evals];
495 | for (var i = 0; data.evals && i < data.evals.length; i++) {
496 | window.HTMLWidgets.evaluateStringMember(data.x, data.evals[i]);
497 | }
498 | if (!bindingDef.renderOnNullValue) {
499 | if (data.x === null) {
500 | el.style.visibility = "hidden";
501 | return;
502 | } else {
503 | el.style.visibility = "inherit";
504 | }
505 | }
506 | if (!elementData(el, "initialized")) {
507 | initSizing(el);
508 |
509 | elementData(el, "initialized", true);
510 | if (bindingDef.initialize) {
511 | var result = bindingDef.initialize(el, el.offsetWidth,
512 | el.offsetHeight);
513 | elementData(el, "init_result", result);
514 | }
515 | }
516 | bindingDef.renderValue(el, data.x, elementData(el, "init_result"));
517 | evalAndRun(data.jsHooks.render, elementData(el, "init_result"), [el, data.x]);
518 | };
519 |
520 | // Only override resize if bindingDef implements it
521 | if (bindingDef.resize) {
522 | shinyBinding.resize = function(el, width, height) {
523 | // Shiny can call resize before initialize/renderValue have been
524 | // called, which doesn't make sense for widgets.
525 | if (elementData(el, "initialized")) {
526 | bindingDef.resize(el, width, height, elementData(el, "init_result"));
527 | }
528 | };
529 | }
530 |
531 | Shiny.outputBindings.register(shinyBinding, bindingDef.name);
532 | }
533 | };
534 |
535 | var scheduleStaticRenderTimerId = null;
536 | function scheduleStaticRender() {
537 | if (!scheduleStaticRenderTimerId) {
538 | scheduleStaticRenderTimerId = setTimeout(function() {
539 | scheduleStaticRenderTimerId = null;
540 | window.HTMLWidgets.staticRender();
541 | }, 1);
542 | }
543 | }
544 |
545 | // Render static widgets after the document finishes loading
546 | // Statically render all elements that are of this widget's class
547 | window.HTMLWidgets.staticRender = function() {
548 | var bindings = window.HTMLWidgets.widgets || [];
549 | forEach(bindings, function(binding) {
550 | var matches = binding.find(document.documentElement);
551 | forEach(matches, function(el) {
552 | var sizeObj = initSizing(el, binding);
553 |
554 | if (hasClass(el, "html-widget-static-bound"))
555 | return;
556 | el.className = el.className + " html-widget-static-bound";
557 |
558 | var initResult;
559 | if (binding.initialize) {
560 | initResult = binding.initialize(el,
561 | sizeObj ? sizeObj.getWidth() : el.offsetWidth,
562 | sizeObj ? sizeObj.getHeight() : el.offsetHeight
563 | );
564 | elementData(el, "init_result", initResult);
565 | }
566 |
567 | if (binding.resize) {
568 | var lastSize = {
569 | w: sizeObj ? sizeObj.getWidth() : el.offsetWidth,
570 | h: sizeObj ? sizeObj.getHeight() : el.offsetHeight
571 | };
572 | var resizeHandler = function(e) {
573 | var size = {
574 | w: sizeObj ? sizeObj.getWidth() : el.offsetWidth,
575 | h: sizeObj ? sizeObj.getHeight() : el.offsetHeight
576 | };
577 | if (size.w === 0 && size.h === 0)
578 | return;
579 | if (size.w === lastSize.w && size.h === lastSize.h)
580 | return;
581 | lastSize = size;
582 | binding.resize(el, size.w, size.h, initResult);
583 | };
584 |
585 | on(window, "resize", resizeHandler);
586 |
587 | // This is needed for cases where we're running in a Shiny
588 | // app, but the widget itself is not a Shiny output, but
589 | // rather a simple static widget. One example of this is
590 | // an rmarkdown document that has runtime:shiny and widget
591 | // that isn't in a render function. Shiny only knows to
592 | // call resize handlers for Shiny outputs, not for static
593 | // widgets, so we do it ourselves.
594 | if (window.jQuery) {
595 | window.jQuery(document).on(
596 | "shown.htmlwidgets shown.bs.tab.htmlwidgets shown.bs.collapse.htmlwidgets",
597 | resizeHandler
598 | );
599 | window.jQuery(document).on(
600 | "hidden.htmlwidgets hidden.bs.tab.htmlwidgets hidden.bs.collapse.htmlwidgets",
601 | resizeHandler
602 | );
603 | }
604 |
605 | // This is needed for the specific case of ioslides, which
606 | // flips slides between display:none and display:block.
607 | // Ideally we would not have to have ioslide-specific code
608 | // here, but rather have ioslides raise a generic event,
609 | // but the rmarkdown package just went to CRAN so the
610 | // window to getting that fixed may be long.
611 | if (window.addEventListener) {
612 | // It's OK to limit this to window.addEventListener
613 | // browsers because ioslides itself only supports
614 | // such browsers.
615 | on(document, "slideenter", resizeHandler);
616 | on(document, "slideleave", resizeHandler);
617 | }
618 | }
619 |
620 | var scriptData = document.querySelector("script[data-for='" + el.id + "'][type='application/json']");
621 | if (scriptData) {
622 | var data = JSON.parse(scriptData.textContent || scriptData.text);
623 | // Resolve strings marked as javascript literals to objects
624 | if (!(data.evals instanceof Array)) data.evals = [data.evals];
625 | for (var k = 0; data.evals && k < data.evals.length; k++) {
626 | window.HTMLWidgets.evaluateStringMember(data.x, data.evals[k]);
627 | }
628 | binding.renderValue(el, data.x, initResult);
629 | evalAndRun(data.jsHooks.render, initResult, [el, data.x]);
630 | }
631 | });
632 | });
633 |
634 | invokePostRenderHandlers();
635 | }
636 |
637 | // Wait until after the document has loaded to render the widgets.
638 | if (document.addEventListener) {
639 | document.addEventListener("DOMContentLoaded", function() {
640 | document.removeEventListener("DOMContentLoaded", arguments.callee, false);
641 | window.HTMLWidgets.staticRender();
642 | }, false);
643 | } else if (document.attachEvent) {
644 | document.attachEvent("onreadystatechange", function() {
645 | if (document.readyState === "complete") {
646 | document.detachEvent("onreadystatechange", arguments.callee);
647 | window.HTMLWidgets.staticRender();
648 | }
649 | });
650 | }
651 |
652 |
653 | window.HTMLWidgets.getAttachmentUrl = function(depname, key) {
654 | // If no key, default to the first item
655 | if (typeof(key) === "undefined")
656 | key = 1;
657 |
658 | var link = document.getElementById(depname + "-" + key + "-attachment");
659 | if (!link) {
660 | throw new Error("Attachment " + depname + "/" + key + " not found in document");
661 | }
662 | return link.getAttribute("href");
663 | };
664 |
665 | window.HTMLWidgets.dataframeToD3 = function(df) {
666 | var names = [];
667 | var length;
668 | for (var name in df) {
669 | if (df.hasOwnProperty(name))
670 | names.push(name);
671 | if (typeof(df[name]) !== "object" || typeof(df[name].length) === "undefined") {
672 | throw new Error("All fields must be arrays");
673 | } else if (typeof(length) !== "undefined" && length !== df[name].length) {
674 | throw new Error("All fields must be arrays of the same length");
675 | }
676 | length = df[name].length;
677 | }
678 | var results = [];
679 | var item;
680 | for (var row = 0; row < length; row++) {
681 | item = {};
682 | for (var col = 0; col < names.length; col++) {
683 | item[names[col]] = df[names[col]][row];
684 | }
685 | results.push(item);
686 | }
687 | return results;
688 | };
689 |
690 | window.HTMLWidgets.transposeArray2D = function(array) {
691 | if (array.length === 0) return array;
692 | var newArray = array[0].map(function(col, i) {
693 | return array.map(function(row) {
694 | return row[i]
695 | })
696 | });
697 | return newArray;
698 | };
699 | // Split value at splitChar, but allow splitChar to be escaped
700 | // using escapeChar. Any other characters escaped by escapeChar
701 | // will be included as usual (including escapeChar itself).
702 | function splitWithEscape(value, splitChar, escapeChar) {
703 | var results = [];
704 | var escapeMode = false;
705 | var currentResult = "";
706 | for (var pos = 0; pos < value.length; pos++) {
707 | if (!escapeMode) {
708 | if (value[pos] === splitChar) {
709 | results.push(currentResult);
710 | currentResult = "";
711 | } else if (value[pos] === escapeChar) {
712 | escapeMode = true;
713 | } else {
714 | currentResult += value[pos];
715 | }
716 | } else {
717 | currentResult += value[pos];
718 | escapeMode = false;
719 | }
720 | }
721 | if (currentResult !== "") {
722 | results.push(currentResult);
723 | }
724 | return results;
725 | }
726 | // Function authored by Yihui/JJ Allaire
727 | window.HTMLWidgets.evaluateStringMember = function(o, member) {
728 | var parts = splitWithEscape(member, '.', '\\');
729 | for (var i = 0, l = parts.length; i < l; i++) {
730 | var part = parts[i];
731 | // part may be a character or 'numeric' member name
732 | if (o !== null && typeof o === "object" && part in o) {
733 | if (i == (l - 1)) { // if we are at the end of the line then evalulate
734 | if (typeof o[part] === "string")
735 | o[part] = eval("(" + o[part] + ")");
736 | } else { // otherwise continue to next embedded object
737 | o = o[part];
738 | }
739 | }
740 | }
741 | };
742 |
743 | // Retrieve the HTMLWidget instance (i.e. the return value of an
744 | // HTMLWidget binding's initialize() or factory() function)
745 | // associated with an element, or null if none.
746 | window.HTMLWidgets.getInstance = function(el) {
747 | return elementData(el, "init_result");
748 | };
749 |
750 | // Finds the first element in the scope that matches the selector,
751 | // and returns the HTMLWidget instance (i.e. the return value of
752 | // an HTMLWidget binding's initialize() or factory() function)
753 | // associated with that element, if any. If no element matches the
754 | // selector, or the first matching element has no HTMLWidget
755 | // instance associated with it, then null is returned.
756 | //
757 | // The scope argument is optional, and defaults to window.document.
758 | window.HTMLWidgets.find = function(scope, selector) {
759 | if (arguments.length == 1) {
760 | selector = scope;
761 | scope = document;
762 | }
763 |
764 | var el = scope.querySelector(selector);
765 | if (el === null) {
766 | return null;
767 | } else {
768 | return window.HTMLWidgets.getInstance(el);
769 | }
770 | };
771 |
772 | // Finds all elements in the scope that match the selector, and
773 | // returns the HTMLWidget instances (i.e. the return values of
774 | // an HTMLWidget binding's initialize() or factory() function)
775 | // associated with the elements, in an array. If elements that
776 | // match the selector don't have an associated HTMLWidget
777 | // instance, the returned array will contain nulls.
778 | //
779 | // The scope argument is optional, and defaults to window.document.
780 | window.HTMLWidgets.findAll = function(scope, selector) {
781 | if (arguments.length == 1) {
782 | selector = scope;
783 | scope = document;
784 | }
785 |
786 | var nodes = scope.querySelectorAll(selector);
787 | var results = [];
788 | for (var i = 0; i < nodes.length; i++) {
789 | results.push(window.HTMLWidgets.getInstance(nodes[i]));
790 | }
791 | return results;
792 | };
793 |
794 | var postRenderHandlers = [];
795 | function invokePostRenderHandlers() {
796 | while (postRenderHandlers.length) {
797 | var handler = postRenderHandlers.shift();
798 | if (handler) {
799 | handler();
800 | }
801 | }
802 | }
803 |
804 | // Register the given callback function to be invoked after the
805 | // next time static widgets are rendered.
806 | window.HTMLWidgets.addPostRenderHandler = function(callback) {
807 | postRenderHandlers.push(callback);
808 | };
809 |
810 | // Takes a new-style instance-bound definition, and returns an
811 | // old-style class-bound definition. This saves us from having
812 | // to rewrite all the logic in this file to accomodate both
813 | // types of definitions.
814 | function createLegacyDefinitionAdapter(defn) {
815 | var result = {
816 | name: defn.name,
817 | type: defn.type,
818 | initialize: function(el, width, height) {
819 | return defn.factory(el, width, height);
820 | },
821 | renderValue: function(el, x, instance) {
822 | return instance.renderValue(x);
823 | },
824 | resize: function(el, width, height, instance) {
825 | return instance.resize(width, height);
826 | }
827 | };
828 |
829 | if (defn.find)
830 | result.find = defn.find;
831 | if (defn.renderError)
832 | result.renderError = defn.renderError;
833 | if (defn.clearError)
834 | result.clearError = defn.clearError;
835 |
836 | return result;
837 | }
838 | })();
839 |
840 |
--------------------------------------------------------------------------------
/libs/jquery/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright 2005, 2014 jQuery Foundation and other contributors,
2 | https://jquery.org/
3 |
4 | This software consists of voluntary contributions made by many
5 | individuals. For exact contribution history, see the revision history
6 | available at https://github.com/jquery/jquery
7 |
8 | The following license applies to all parts of this software except as
9 | documented below:
10 |
11 | ====
12 |
13 | Permission is hereby granted, free of charge, to any person obtaining
14 | a copy of this software and associated documentation files (the
15 | "Software"), to deal in the Software without restriction, including
16 | without limitation the rights to use, copy, modify, merge, publish,
17 | distribute, sublicense, and/or sell copies of the Software, and to
18 | permit persons to whom the Software is furnished to do so, subject to
19 | the following conditions:
20 |
21 | The above copyright notice and this permission notice shall be
22 | included in all copies or substantial portions of the Software.
23 |
24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 |
32 | ====
33 |
34 | All files located in the node_modules and external directories are
35 | externally maintained libraries used by this software which have their
36 | own licenses; we recommend you read them, as their terms may differ from
37 | the terms above.
38 |
--------------------------------------------------------------------------------
/libs/leaflet/images/layers-2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amrrs/r_beginners_workshop/1971ded361f43811a542583a43a0e82fd256642e/libs/leaflet/images/layers-2x.png
--------------------------------------------------------------------------------
/libs/leaflet/images/layers.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amrrs/r_beginners_workshop/1971ded361f43811a542583a43a0e82fd256642e/libs/leaflet/images/layers.png
--------------------------------------------------------------------------------
/libs/leaflet/images/marker-icon-2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amrrs/r_beginners_workshop/1971ded361f43811a542583a43a0e82fd256642e/libs/leaflet/images/marker-icon-2x.png
--------------------------------------------------------------------------------
/libs/leaflet/images/marker-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amrrs/r_beginners_workshop/1971ded361f43811a542583a43a0e82fd256642e/libs/leaflet/images/marker-icon.png
--------------------------------------------------------------------------------
/libs/leaflet/images/marker-shadow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amrrs/r_beginners_workshop/1971ded361f43811a542583a43a0e82fd256642e/libs/leaflet/images/marker-shadow.png
--------------------------------------------------------------------------------
/libs/leaflet/leaflet.css:
--------------------------------------------------------------------------------
1 | /* required styles */
2 |
3 | .leaflet-pane,
4 | .leaflet-tile,
5 | .leaflet-marker-icon,
6 | .leaflet-marker-shadow,
7 | .leaflet-tile-container,
8 | .leaflet-pane > svg,
9 | .leaflet-pane > canvas,
10 | .leaflet-zoom-box,
11 | .leaflet-image-layer,
12 | .leaflet-layer {
13 | position: absolute;
14 | left: 0;
15 | top: 0;
16 | }
17 | .leaflet-container {
18 | overflow: hidden;
19 | }
20 | .leaflet-tile,
21 | .leaflet-marker-icon,
22 | .leaflet-marker-shadow {
23 | -webkit-user-select: none;
24 | -moz-user-select: none;
25 | user-select: none;
26 | -webkit-user-drag: none;
27 | }
28 | /* Safari renders non-retina tile on retina better with this, but Chrome is worse */
29 | .leaflet-safari .leaflet-tile {
30 | image-rendering: -webkit-optimize-contrast;
31 | }
32 | /* hack that prevents hw layers "stretching" when loading new tiles */
33 | .leaflet-safari .leaflet-tile-container {
34 | width: 1600px;
35 | height: 1600px;
36 | -webkit-transform-origin: 0 0;
37 | }
38 | .leaflet-marker-icon,
39 | .leaflet-marker-shadow {
40 | display: block;
41 | }
42 | /* .leaflet-container svg: reset svg max-width decleration shipped in Joomla! (joomla.org) 3.x */
43 | /* .leaflet-container img: map is broken in FF if you have max-width: 100% on tiles */
44 | .leaflet-container .leaflet-overlay-pane svg,
45 | .leaflet-container .leaflet-marker-pane img,
46 | .leaflet-container .leaflet-shadow-pane img,
47 | .leaflet-container .leaflet-tile-pane img,
48 | .leaflet-container img.leaflet-image-layer {
49 | max-width: none !important;
50 | max-height: none !important;
51 | }
52 |
53 | .leaflet-container.leaflet-touch-zoom {
54 | -ms-touch-action: pan-x pan-y;
55 | touch-action: pan-x pan-y;
56 | }
57 | .leaflet-container.leaflet-touch-drag {
58 | -ms-touch-action: pinch-zoom;
59 | /* Fallback for FF which doesn't support pinch-zoom */
60 | touch-action: none;
61 | touch-action: pinch-zoom;
62 | }
63 | .leaflet-container.leaflet-touch-drag.leaflet-touch-zoom {
64 | -ms-touch-action: none;
65 | touch-action: none;
66 | }
67 | .leaflet-container {
68 | -webkit-tap-highlight-color: transparent;
69 | }
70 | .leaflet-container a {
71 | -webkit-tap-highlight-color: rgba(51, 181, 229, 0.4);
72 | }
73 | .leaflet-tile {
74 | filter: inherit;
75 | visibility: hidden;
76 | }
77 | .leaflet-tile-loaded {
78 | visibility: inherit;
79 | }
80 | .leaflet-zoom-box {
81 | width: 0;
82 | height: 0;
83 | -moz-box-sizing: border-box;
84 | box-sizing: border-box;
85 | z-index: 800;
86 | }
87 | /* workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=888319 */
88 | .leaflet-overlay-pane svg {
89 | -moz-user-select: none;
90 | }
91 |
92 | .leaflet-pane { z-index: 400; }
93 |
94 | .leaflet-tile-pane { z-index: 200; }
95 | .leaflet-overlay-pane { z-index: 400; }
96 | .leaflet-shadow-pane { z-index: 500; }
97 | .leaflet-marker-pane { z-index: 600; }
98 | .leaflet-tooltip-pane { z-index: 650; }
99 | .leaflet-popup-pane { z-index: 700; }
100 |
101 | .leaflet-map-pane canvas { z-index: 100; }
102 | .leaflet-map-pane svg { z-index: 200; }
103 |
104 | .leaflet-vml-shape {
105 | width: 1px;
106 | height: 1px;
107 | }
108 | .lvml {
109 | behavior: url(#default#VML);
110 | display: inline-block;
111 | position: absolute;
112 | }
113 |
114 |
115 | /* control positioning */
116 |
117 | .leaflet-control {
118 | position: relative;
119 | z-index: 800;
120 | pointer-events: visiblePainted; /* IE 9-10 doesn't have auto */
121 | pointer-events: auto;
122 | }
123 | .leaflet-top,
124 | .leaflet-bottom {
125 | position: absolute;
126 | z-index: 1000;
127 | pointer-events: none;
128 | }
129 | .leaflet-top {
130 | top: 0;
131 | }
132 | .leaflet-right {
133 | right: 0;
134 | }
135 | .leaflet-bottom {
136 | bottom: 0;
137 | }
138 | .leaflet-left {
139 | left: 0;
140 | }
141 | .leaflet-control {
142 | float: left;
143 | clear: both;
144 | }
145 | .leaflet-right .leaflet-control {
146 | float: right;
147 | }
148 | .leaflet-top .leaflet-control {
149 | margin-top: 10px;
150 | }
151 | .leaflet-bottom .leaflet-control {
152 | margin-bottom: 10px;
153 | }
154 | .leaflet-left .leaflet-control {
155 | margin-left: 10px;
156 | }
157 | .leaflet-right .leaflet-control {
158 | margin-right: 10px;
159 | }
160 |
161 |
162 | /* zoom and fade animations */
163 |
164 | .leaflet-fade-anim .leaflet-tile {
165 | will-change: opacity;
166 | }
167 | .leaflet-fade-anim .leaflet-popup {
168 | opacity: 0;
169 | -webkit-transition: opacity 0.2s linear;
170 | -moz-transition: opacity 0.2s linear;
171 | -o-transition: opacity 0.2s linear;
172 | transition: opacity 0.2s linear;
173 | }
174 | .leaflet-fade-anim .leaflet-map-pane .leaflet-popup {
175 | opacity: 1;
176 | }
177 | .leaflet-zoom-animated {
178 | -webkit-transform-origin: 0 0;
179 | -ms-transform-origin: 0 0;
180 | transform-origin: 0 0;
181 | }
182 | .leaflet-zoom-anim .leaflet-zoom-animated {
183 | will-change: transform;
184 | }
185 | .leaflet-zoom-anim .leaflet-zoom-animated {
186 | -webkit-transition: -webkit-transform 0.25s cubic-bezier(0,0,0.25,1);
187 | -moz-transition: -moz-transform 0.25s cubic-bezier(0,0,0.25,1);
188 | -o-transition: -o-transform 0.25s cubic-bezier(0,0,0.25,1);
189 | transition: transform 0.25s cubic-bezier(0,0,0.25,1);
190 | }
191 | .leaflet-zoom-anim .leaflet-tile,
192 | .leaflet-pan-anim .leaflet-tile {
193 | -webkit-transition: none;
194 | -moz-transition: none;
195 | -o-transition: none;
196 | transition: none;
197 | }
198 |
199 | .leaflet-zoom-anim .leaflet-zoom-hide {
200 | visibility: hidden;
201 | }
202 |
203 |
204 | /* cursors */
205 |
206 | .leaflet-interactive {
207 | cursor: pointer;
208 | }
209 | .leaflet-grab {
210 | cursor: -webkit-grab;
211 | cursor: -moz-grab;
212 | }
213 | .leaflet-crosshair,
214 | .leaflet-crosshair .leaflet-interactive {
215 | cursor: crosshair;
216 | }
217 | .leaflet-popup-pane,
218 | .leaflet-control {
219 | cursor: auto;
220 | }
221 | .leaflet-dragging .leaflet-grab,
222 | .leaflet-dragging .leaflet-grab .leaflet-interactive,
223 | .leaflet-dragging .leaflet-marker-draggable {
224 | cursor: move;
225 | cursor: -webkit-grabbing;
226 | cursor: -moz-grabbing;
227 | }
228 |
229 | /* marker & overlays interactivity */
230 | .leaflet-marker-icon,
231 | .leaflet-marker-shadow,
232 | .leaflet-image-layer,
233 | .leaflet-pane > svg path,
234 | .leaflet-tile-container {
235 | pointer-events: none;
236 | }
237 |
238 | .leaflet-marker-icon.leaflet-interactive,
239 | .leaflet-image-layer.leaflet-interactive,
240 | .leaflet-pane > svg path.leaflet-interactive {
241 | pointer-events: visiblePainted; /* IE 9-10 doesn't have auto */
242 | pointer-events: auto;
243 | }
244 |
245 | /* visual tweaks */
246 |
247 | .leaflet-container {
248 | background: #ddd;
249 | outline: 0;
250 | }
251 | .leaflet-container a {
252 | color: #0078A8;
253 | }
254 | .leaflet-container a.leaflet-active {
255 | outline: 2px solid orange;
256 | }
257 | .leaflet-zoom-box {
258 | border: 2px dotted #38f;
259 | background: rgba(255,255,255,0.5);
260 | }
261 |
262 |
263 | /* general typography */
264 | .leaflet-container {
265 | font: 12px/1.5 "Helvetica Neue", Arial, Helvetica, sans-serif;
266 | }
267 |
268 |
269 | /* general toolbar styles */
270 |
271 | .leaflet-bar {
272 | box-shadow: 0 1px 5px rgba(0,0,0,0.65);
273 | border-radius: 4px;
274 | }
275 | .leaflet-bar a,
276 | .leaflet-bar a:hover {
277 | background-color: #fff;
278 | border-bottom: 1px solid #ccc;
279 | width: 26px;
280 | height: 26px;
281 | line-height: 26px;
282 | display: block;
283 | text-align: center;
284 | text-decoration: none;
285 | color: black;
286 | }
287 | .leaflet-bar a,
288 | .leaflet-control-layers-toggle {
289 | background-position: 50% 50%;
290 | background-repeat: no-repeat;
291 | display: block;
292 | }
293 | .leaflet-bar a:hover {
294 | background-color: #f4f4f4;
295 | }
296 | .leaflet-bar a:first-child {
297 | border-top-left-radius: 4px;
298 | border-top-right-radius: 4px;
299 | }
300 | .leaflet-bar a:last-child {
301 | border-bottom-left-radius: 4px;
302 | border-bottom-right-radius: 4px;
303 | border-bottom: none;
304 | }
305 | .leaflet-bar a.leaflet-disabled {
306 | cursor: default;
307 | background-color: #f4f4f4;
308 | color: #bbb;
309 | }
310 |
311 | .leaflet-touch .leaflet-bar a {
312 | width: 30px;
313 | height: 30px;
314 | line-height: 30px;
315 | }
316 | .leaflet-touch .leaflet-bar a:first-child {
317 | border-top-left-radius: 2px;
318 | border-top-right-radius: 2px;
319 | }
320 | .leaflet-touch .leaflet-bar a:last-child {
321 | border-bottom-left-radius: 2px;
322 | border-bottom-right-radius: 2px;
323 | }
324 |
325 | /* zoom control */
326 |
327 | .leaflet-control-zoom-in,
328 | .leaflet-control-zoom-out {
329 | font: bold 18px 'Lucida Console', Monaco, monospace;
330 | text-indent: 1px;
331 | }
332 |
333 | .leaflet-touch .leaflet-control-zoom-in, .leaflet-touch .leaflet-control-zoom-out {
334 | font-size: 22px;
335 | }
336 |
337 |
338 | /* layers control */
339 |
340 | .leaflet-control-layers {
341 | box-shadow: 0 1px 5px rgba(0,0,0,0.4);
342 | background: #fff;
343 | border-radius: 5px;
344 | }
345 | .leaflet-control-layers-toggle {
346 | background-image: url(images/layers.png);
347 | width: 36px;
348 | height: 36px;
349 | }
350 | .leaflet-retina .leaflet-control-layers-toggle {
351 | background-image: url(images/layers-2x.png);
352 | background-size: 26px 26px;
353 | }
354 | .leaflet-touch .leaflet-control-layers-toggle {
355 | width: 44px;
356 | height: 44px;
357 | }
358 | .leaflet-control-layers .leaflet-control-layers-list,
359 | .leaflet-control-layers-expanded .leaflet-control-layers-toggle {
360 | display: none;
361 | }
362 | .leaflet-control-layers-expanded .leaflet-control-layers-list {
363 | display: block;
364 | position: relative;
365 | }
366 | .leaflet-control-layers-expanded {
367 | padding: 6px 10px 6px 6px;
368 | color: #333;
369 | background: #fff;
370 | }
371 | .leaflet-control-layers-scrollbar {
372 | overflow-y: scroll;
373 | overflow-x: hidden;
374 | padding-right: 5px;
375 | }
376 | .leaflet-control-layers-selector {
377 | margin-top: 2px;
378 | position: relative;
379 | top: 1px;
380 | }
381 | .leaflet-control-layers label {
382 | display: block;
383 | }
384 | .leaflet-control-layers-separator {
385 | height: 0;
386 | border-top: 1px solid #ddd;
387 | margin: 5px -10px 5px -6px;
388 | }
389 |
390 | /* Default icon URLs */
391 | .leaflet-default-icon-path {
392 | background-image: url(images/marker-icon.png);
393 | }
394 |
395 |
396 | /* attribution and scale controls */
397 |
398 | .leaflet-container .leaflet-control-attribution {
399 | background: #fff;
400 | background: rgba(255, 255, 255, 0.7);
401 | margin: 0;
402 | }
403 | .leaflet-control-attribution,
404 | .leaflet-control-scale-line {
405 | padding: 0 5px;
406 | color: #333;
407 | }
408 | .leaflet-control-attribution a {
409 | text-decoration: none;
410 | }
411 | .leaflet-control-attribution a:hover {
412 | text-decoration: underline;
413 | }
414 | .leaflet-container .leaflet-control-attribution,
415 | .leaflet-container .leaflet-control-scale {
416 | font-size: 11px;
417 | }
418 | .leaflet-left .leaflet-control-scale {
419 | margin-left: 5px;
420 | }
421 | .leaflet-bottom .leaflet-control-scale {
422 | margin-bottom: 5px;
423 | }
424 | .leaflet-control-scale-line {
425 | border: 2px solid #777;
426 | border-top: none;
427 | line-height: 1.1;
428 | padding: 2px 5px 1px;
429 | font-size: 11px;
430 | white-space: nowrap;
431 | overflow: hidden;
432 | -moz-box-sizing: border-box;
433 | box-sizing: border-box;
434 |
435 | background: #fff;
436 | background: rgba(255, 255, 255, 0.5);
437 | }
438 | .leaflet-control-scale-line:not(:first-child) {
439 | border-top: 2px solid #777;
440 | border-bottom: none;
441 | margin-top: -2px;
442 | }
443 | .leaflet-control-scale-line:not(:first-child):not(:last-child) {
444 | border-bottom: 2px solid #777;
445 | }
446 |
447 | .leaflet-touch .leaflet-control-attribution,
448 | .leaflet-touch .leaflet-control-layers,
449 | .leaflet-touch .leaflet-bar {
450 | box-shadow: none;
451 | }
452 | .leaflet-touch .leaflet-control-layers,
453 | .leaflet-touch .leaflet-bar {
454 | border: 2px solid rgba(0,0,0,0.2);
455 | background-clip: padding-box;
456 | }
457 |
458 |
459 | /* popup */
460 |
461 | .leaflet-popup {
462 | position: absolute;
463 | text-align: center;
464 | margin-bottom: 20px;
465 | }
466 | .leaflet-popup-content-wrapper {
467 | padding: 1px;
468 | text-align: left;
469 | border-radius: 12px;
470 | }
471 | .leaflet-popup-content {
472 | margin: 13px 19px;
473 | line-height: 1.4;
474 | }
475 | .leaflet-popup-content p {
476 | margin: 18px 0;
477 | }
478 | .leaflet-popup-tip-container {
479 | width: 40px;
480 | height: 20px;
481 | position: absolute;
482 | left: 50%;
483 | margin-left: -20px;
484 | overflow: hidden;
485 | pointer-events: none;
486 | }
487 | .leaflet-popup-tip {
488 | width: 17px;
489 | height: 17px;
490 | padding: 1px;
491 |
492 | margin: -10px auto 0;
493 |
494 | -webkit-transform: rotate(45deg);
495 | -moz-transform: rotate(45deg);
496 | -ms-transform: rotate(45deg);
497 | -o-transform: rotate(45deg);
498 | transform: rotate(45deg);
499 | }
500 | .leaflet-popup-content-wrapper,
501 | .leaflet-popup-tip {
502 | background: white;
503 | color: #333;
504 | box-shadow: 0 3px 14px rgba(0,0,0,0.4);
505 | }
506 | .leaflet-container a.leaflet-popup-close-button {
507 | position: absolute;
508 | top: 0;
509 | right: 0;
510 | padding: 4px 4px 0 0;
511 | border: none;
512 | text-align: center;
513 | width: 18px;
514 | height: 14px;
515 | font: 16px/14px Tahoma, Verdana, sans-serif;
516 | color: #c3c3c3;
517 | text-decoration: none;
518 | font-weight: bold;
519 | background: transparent;
520 | }
521 | .leaflet-container a.leaflet-popup-close-button:hover {
522 | color: #999;
523 | }
524 | .leaflet-popup-scrolled {
525 | overflow: auto;
526 | border-bottom: 1px solid #ddd;
527 | border-top: 1px solid #ddd;
528 | }
529 |
530 | .leaflet-oldie .leaflet-popup-content-wrapper {
531 | zoom: 1;
532 | }
533 | .leaflet-oldie .leaflet-popup-tip {
534 | width: 24px;
535 | margin: 0 auto;
536 |
537 | -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)";
538 | filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678);
539 | }
540 | .leaflet-oldie .leaflet-popup-tip-container {
541 | margin-top: -1px;
542 | }
543 |
544 | .leaflet-oldie .leaflet-control-zoom,
545 | .leaflet-oldie .leaflet-control-layers,
546 | .leaflet-oldie .leaflet-popup-content-wrapper,
547 | .leaflet-oldie .leaflet-popup-tip {
548 | border: 1px solid #999;
549 | }
550 |
551 |
552 | /* div icon */
553 |
554 | .leaflet-div-icon {
555 | background: #fff;
556 | border: 1px solid #666;
557 | }
558 |
559 |
560 | /* Tooltip */
561 | /* Base styles for the element that has a tooltip */
562 | .leaflet-tooltip {
563 | position: absolute;
564 | padding: 6px;
565 | background-color: #fff;
566 | border: 1px solid #fff;
567 | border-radius: 3px;
568 | color: #222;
569 | white-space: nowrap;
570 | -webkit-user-select: none;
571 | -moz-user-select: none;
572 | -ms-user-select: none;
573 | user-select: none;
574 | pointer-events: none;
575 | box-shadow: 0 1px 3px rgba(0,0,0,0.4);
576 | }
577 | .leaflet-tooltip.leaflet-clickable {
578 | cursor: pointer;
579 | pointer-events: auto;
580 | }
581 | .leaflet-tooltip-top:before,
582 | .leaflet-tooltip-bottom:before,
583 | .leaflet-tooltip-left:before,
584 | .leaflet-tooltip-right:before {
585 | position: absolute;
586 | pointer-events: none;
587 | border: 6px solid transparent;
588 | background: transparent;
589 | content: "";
590 | }
591 |
592 | /* Directions */
593 |
594 | .leaflet-tooltip-bottom {
595 | margin-top: 6px;
596 | }
597 | .leaflet-tooltip-top {
598 | margin-top: -6px;
599 | }
600 | .leaflet-tooltip-bottom:before,
601 | .leaflet-tooltip-top:before {
602 | left: 50%;
603 | margin-left: -6px;
604 | }
605 | .leaflet-tooltip-top:before {
606 | bottom: 0;
607 | margin-bottom: -12px;
608 | border-top-color: #fff;
609 | }
610 | .leaflet-tooltip-bottom:before {
611 | top: 0;
612 | margin-top: -12px;
613 | margin-left: -6px;
614 | border-bottom-color: #fff;
615 | }
616 | .leaflet-tooltip-left {
617 | margin-left: -6px;
618 | }
619 | .leaflet-tooltip-right {
620 | margin-left: 6px;
621 | }
622 | .leaflet-tooltip-left:before,
623 | .leaflet-tooltip-right:before {
624 | top: 50%;
625 | margin-top: -6px;
626 | }
627 | .leaflet-tooltip-left:before {
628 | right: 0;
629 | margin-right: -12px;
630 | border-left-color: #fff;
631 | }
632 | .leaflet-tooltip-right:before {
633 | left: 0;
634 | margin-left: -12px;
635 | border-right-color: #fff;
636 | }
637 |
--------------------------------------------------------------------------------
/libs/leafletfix/leafletfix.css:
--------------------------------------------------------------------------------
1 | /* Work around CSS properties introduced on img by bootstrap */
2 | img.leaflet-tile {
3 | padding: 0;
4 | margin: 0;
5 | border-radius: 0;
6 | border: none;
7 | }
8 | .info {
9 | padding: 6px 8px;
10 | font: 14px/16px Arial, Helvetica, sans-serif;
11 | background: white;
12 | background: rgba(255,255,255,0.8);
13 | box-shadow: 0 0 15px rgba(0,0,0,0.2);
14 | border-radius: 5px;
15 | }
16 | .legend {
17 | line-height: 18px;
18 | color: #555;
19 | }
20 | .legend svg text {
21 | fill: #555;
22 | }
23 | .legend svg line {
24 | stroke: #555;
25 | }
26 | .legend i {
27 | width: 18px;
28 | height: 18px;
29 | margin-right: 4px;
30 | opacity: 0.7;
31 | display: inline-block;
32 | vertical-align: top;
33 | /*For IE 7*/
34 | zoom: 1;
35 | *display: inline;
36 | }
37 |
--------------------------------------------------------------------------------
/libs/remark-css/default-fonts.css:
--------------------------------------------------------------------------------
1 | @import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz);
2 | @import url(https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic);
3 | @import url(https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700);
4 |
5 | body { font-family: 'Droid Serif', 'Palatino Linotype', 'Book Antiqua', Palatino, 'Microsoft YaHei', 'Songti SC', serif; }
6 | h1, h2, h3 {
7 | font-family: 'Yanone Kaffeesatz';
8 | font-weight: normal;
9 | }
10 | .remark-code, .remark-inline-code { font-family: 'Source Code Pro', 'Lucida Console', Monaco, monospace; }
11 |
--------------------------------------------------------------------------------
/libs/remark-css/default.css:
--------------------------------------------------------------------------------
1 | a, a > code {
2 | color: rgb(249, 38, 114);
3 | text-decoration: none;
4 | }
5 | .footnote {
6 | position: absolute;
7 | bottom: 3em;
8 | padding-right: 4em;
9 | font-size: 90%;
10 | }
11 | .remark-code-line-highlighted { background-color: #ffff88; }
12 |
13 | .inverse {
14 | background-color: #272822;
15 | color: #d6d6d6;
16 | text-shadow: 0 0 20px #333;
17 | }
18 | .inverse h1, .inverse h2, .inverse h3 {
19 | color: #f3f3f3;
20 | }
21 | /* Two-column layout */
22 | .left-column {
23 | color: #777;
24 | width: 20%;
25 | height: 92%;
26 | float: left;
27 | }
28 | .left-column h2:last-of-type, .left-column h3:last-child {
29 | color: #000;
30 | }
31 | .right-column {
32 | width: 75%;
33 | float: right;
34 | padding-top: 1em;
35 | }
36 | .pull-left {
37 | float: left;
38 | width: 47%;
39 | }
40 | .pull-right {
41 | float: right;
42 | width: 47%;
43 | }
44 | .pull-right ~ * {
45 | clear: both;
46 | }
47 | img, video, iframe {
48 | max-width: 100%;
49 | }
50 | blockquote {
51 | border-left: solid 5px lightgray;
52 | padding-left: 1em;
53 | }
54 | .remark-slide table {
55 | margin: auto;
56 | border-top: 1px solid #666;
57 | border-bottom: 1px solid #666;
58 | }
59 | .remark-slide table thead th { border-bottom: 1px solid #ddd; }
60 | th, td { padding: 5px; }
61 | .remark-slide thead, .remark-slide tfoot, .remark-slide tr:nth-child(even) { background: #eee }
62 |
63 | @page { margin: 0; }
64 | @media print {
65 | .remark-slide-scaler {
66 | width: 100% !important;
67 | height: 100% !important;
68 | transform: scale(1) !important;
69 | top: 0 !important;
70 | left: 0 !important;
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/libs/rstudio_leaflet/images/1px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amrrs/r_beginners_workshop/1971ded361f43811a542583a43a0e82fd256642e/libs/rstudio_leaflet/images/1px.png
--------------------------------------------------------------------------------
/libs/rstudio_leaflet/rstudio_leaflet.css:
--------------------------------------------------------------------------------
1 | .leaflet-tooltip.leaflet-tooltip-text-only,
2 | .leaflet-tooltip.leaflet-tooltip-text-only:before,
3 | .leaflet-tooltip.leaflet-tooltip-text-only:after {
4 | background: none;
5 | border: none;
6 | box-shadow: none;
7 | }
8 |
9 | .leaflet-tooltip.leaflet-tooltip-text-only.leaflet-tooltip-left {
10 | margin-left: 5px;
11 | }
12 |
13 | .leaflet-tooltip.leaflet-tooltip-text-only.leaflet-tooltip-right {
14 | margin-left: -5px;
15 | }
16 |
17 | .leaflet-tooltip:after {
18 | border-right: 6px solid transparent;
19 | /* right: -16px; */
20 | }
21 |
22 | .leaflet-popup-pane .leaflet-popup-tip-container {
23 | /* when the tooltip container is clicked, it is closed */
24 | pointer-events: all;
25 | /* tooltips should display the "hand" icon, just like .leaflet-interactive*/
26 | cursor: pointer;
27 | }
28 |
29 | /* have the widget be displayed in the right 'layer' */
30 | .leaflet-map-pane {
31 | z-index: auto;
32 | }
33 |
--------------------------------------------------------------------------------
/presentation.Rmd:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Intro to R for Data Science"
3 | subtitle: "Beginner's workshop"
4 | author: "AbdulMajedRaja RS"
5 | output:
6 | xaringan::moon_reader:
7 | chakra: libs/remark-latest.min.js
8 | lib_dir: libs
9 | nature:
10 | highlightStyle: github
11 | highlightLines: true
12 | countIncrementalSlides: false
13 | ---
14 |
15 | ```{r setup, include=FALSE}
16 | options(htmltools.dir.version = FALSE)
17 | ```
18 |
19 |
20 | # About Me
21 |
22 | - Studied at **Government College of Technology, Coimbatore**
23 |
24 | - Bengaluru R user group **Organizer**
25 |
26 | - R Packages Developer ( `coinmarketcapr`, `itunesr`)
27 |
28 |
29 | ---
30 |
31 | class: inverse
32 |
33 | # Disclaimer:
34 |
35 | - This workshop is **NOT** going to make you a Data Scientist **in a day**.
36 |
37 | - The objective is to help you get a flavor of R and how it is used in Data Science
38 |
39 | - Thus, get you ready to embark on your own journey to become a Data Scientist who uses R
40 |
41 |
42 | ---
43 |
44 | # Content:
45 |
46 | This presentation's content is heavily borrowed from the book [**R for Data Science**](https://r4ds.had.co.nz) by **Garrett Grolemund** and **Hadley Wickham**
47 |
48 |
49 | .center[

]
50 |
51 | ---
52 |
53 |
54 | # About R
55 |
56 | - R is a language and environment for statistical computing and graphics. (Ref: [`r-project.org`](https://www.r-project.org/about.html))
57 |
58 | - R was created by Ross Ihaka and Robert Gentleman at the University of Auckland, New Zealand
59 |
60 | - R is Free
61 |
62 | - R can be extended (easily) via *packages*.
63 |
64 | - R is an interpreted language
65 |
66 |
67 | .right[]
68 |
69 |
70 | ---
71 | class: inverse, center, middle
72 |
73 | # R Interpreter / Console / GUI
74 | ## Demo
75 | ---
76 |
77 | # About RStudio
78 |
79 |
80 | - RStudio is a **free and open-source IDE** for R, released by the company **RStudio, Inc.**
81 |
82 | - RStudio and its team regularly contribute to R community by releasing new packages, such as:
83 | - `tidyverse`
84 | - `shiny`
85 | - `knitr`
86 |
87 |
88 | .right[

]
89 |
90 |
91 | ---
92 | class: inverse, center, middle
93 |
94 | # RStudio
95 | ## Demo
96 |
97 |
98 | ---
99 |
100 | # R Ecosystem
101 |
102 | Like `Python`, `R`'s strength lies in its Ecosystem. **Why R?** - R Packages
103 |
104 |
105 | ### Growth
106 |
107 |
108 |
109 |
111 | Source: @daroczig
112 |
113 |
114 |
115 |
116 | ---
117 | class: inverse, center, middle
118 |
119 | # Basics of R Programming
120 |
121 | ---
122 |
123 | # Hello, World!
124 |
125 |
126 | The traditional first step - **Hello, World!**:
127 |
128 | --
129 |
130 | ```{r eval=TRUE, tidy=FALSE}
131 | print("Hello, World!") #<<
132 |
133 | ```
134 |
135 |
136 |
137 | ###.center[That's one small step for a man, one giant leap for mankind]
138 | ###.center[Neil Armstrong]
139 |
140 | ---
141 |
142 | # Arithmetic Operations
143 |
144 | ```{r}
145 | 2 + 3
146 | ```
147 |
148 | ```{r}
149 | 50000 * 42222
150 | ```
151 |
152 | ```{r}
153 | 2304 / 233
154 | ```
155 |
156 | ```{r}
157 | (33 + 44 ) * 232 / 12
158 | ```
159 |
160 | ---
161 |
162 | # Assignment Operators
163 |
164 | ### .center[`<-` **Arrow (Less-than < and Minus - )**]
165 |
166 | ### .center[`=` **(Equal Sign)**]
167 |
168 | ```{r}
169 | (x <- 2 + 3)
170 | ```
171 |
172 |
173 | ```{r}
174 | (y = x ** 4) #<<
175 | ```
176 |
177 | ```{r}
178 | 5 * 9 -> a
179 | a + 3
180 | ```
181 |
182 | ---
183 |
184 |
185 |
186 | # Objects
187 |
188 | * The entities R operates on are technically known as `objects`.
189 |
190 | Example: Vector of numeric
191 |
192 |
193 | ```{r}
194 | vector_of_numeric <- c(2,4,5)
195 |
196 | typeof(vector_of_numeric)
197 | ```
198 |
199 | ---
200 |
201 | # Vectors
202 |
203 | - Atomic Vectors - Homogeneous Data Type
204 |
205 | - logical
206 | - integer
207 | - double
208 | - character
209 | - *complex*
210 | - *raw*
211 |
212 | - Lists - (Recursive Vectors) Heterogeneous Data Type
213 |
214 | - `NULL` is used to represent absence of a vector
215 |
216 | **Vectors + Attributes (Additional Meta Data) = Augmented vectors**
217 |
218 | * Factors are built on top of integer vectors.
219 | * Dates and date-times are built on top of numeric vectors.
220 | * Data frames and tibbles are built on top of lists.
221 |
222 |
223 | ---
224 |
225 | ### Numeric Vector
226 | Each element of the numeric vector should be a number.
227 | ```{r}
228 | nummy <- c(2,3,4)
229 |
230 | nummy_int <- c(1L,2L,3L)
231 | ```
232 |
233 |
234 | ```{r}
235 | typeof(nummy)
236 |
237 | typeof(nummy_int)
238 | ```
239 |
240 | ```{r}
241 | is.numeric(nummy)
242 | is.numeric(nummy_int)
243 |
244 | is.double(nummy)
245 | is.double(nummy_int)
246 | ```
247 |
248 |
249 | ---
250 |
251 | ### Character Vector
252 |
253 | ```{r}
254 |
255 | types <- c("int","double","character")
256 |
257 | types
258 | ```
259 |
260 |
261 | ```{r}
262 | typeof(types)
263 |
264 | length(types)
265 |
266 | ```
267 |
268 | ```{r}
269 | is.numeric(types)
270 | is.character(types)
271 | ```
272 | ---
273 |
274 | ### Logical Vector
275 |
276 | ```{r}
277 |
278 | logicals <- c(TRUE,F,TRUE,T, FALSE)
279 |
280 | logicals
281 | ```
282 | ---
283 |
284 | # Coersion
285 |
286 | ## Typecasting - Explicit
287 |
288 |
289 | ```{r}
290 |
291 | money_in_chars <- c("20","35","33")
292 |
293 | typeof(money_in_chars)
294 |
295 | ```
296 |
297 | ```{r}
298 | money_money <- as.numeric(money_in_chars)
299 |
300 | money_money
301 |
302 | typeof(money_money)
303 | ```
304 |
305 | ---
306 |
307 | ## Typecasting - Implicit
308 |
309 | ```{r}
310 | money_money <- as.numeric(money_in_chars)
311 |
312 | money_money
313 |
314 | typeof(money_money)
315 |
316 | ```
317 |
318 | ```{r}
319 |
320 | new_money <- c(money_money,"33")
321 |
322 | new_money
323 |
324 | typeof(new_money)
325 |
326 | ```
327 |
328 |
329 | ---
330 |
331 | #Vector - Accessing
332 |
333 | ```{r}
334 |
335 | month.abb #in-built character vector with Month Abbreviations
336 |
337 | month.abb[2]
338 |
339 | ```
340 |
341 | ```{r}
342 | month.abb[4:7]
343 | ```
344 |
345 | ```{r}
346 | month.abb[c(2,5,7,10)]
347 | ```
348 |
349 | ---
350 | # Vector Manipulation
351 |
352 | ## Appending
353 |
354 | ```{r}
355 | days <- c("Mon","Tue","Wed")
356 |
357 | days
358 | ```
359 |
360 | ```{r}
361 | week_end <- c("Sat","Sun")
362 |
363 | more_days <- c(days,"Thu","Fri",week_end)
364 |
365 | more_days
366 | ```
367 |
368 | ---
369 |
370 | # Vector - Arithmetic
371 |
372 | ```{r}
373 |
374 | set.seed(122)
375 |
376 | so_many_numbers <- runif(10, min = 10, max = 100)
377 |
378 | so_many_numbers
379 | ```
380 |
381 | ```{r}
382 | so_many_numbers * 200
383 | ```
384 |
385 | ---
386 | # Factors
387 |
388 | * In R, factors are used to work with categorical variables, variables that have a fixed and known set of possible values.
389 |
390 | * Useful with Characters where non-Alphabetical Ordering is required
391 |
392 | ```{r}
393 | days <- c("Thu","Wed","Sun")
394 |
395 | sort(days)
396 | ```
397 |
398 |
399 | ```{r}
400 |
401 | week_levels <- c("Mon","Tue","Wed","Thu","Fri","Sat","Sun")
402 |
403 |
404 | (days_f <- factor(days, levels = week_levels))
405 |
406 | ```
407 |
408 | ```{r}
409 | sort(days_f)
410 | ```
411 |
412 | ---
413 |
414 | # List
415 |
416 | Lists are a step up in complexity from atomic vectors: each element can be any type, not just vectors.
417 |
418 | ```{r}
419 |
420 | (a_list <- list("abcd",123,1:12,month.abb))
421 |
422 | ```
423 | ---
424 |
425 | # List Accessing
426 |
427 | ```{r}
428 | a_list[[1]]
429 |
430 | a_list[[4]][4]
431 | ```
432 |
433 |
434 | ---
435 |
436 | # Matrix
437 |
438 | ```{r}
439 | new_m <- matrix(data = 1:12, nrow = 3)
440 |
441 | new_m
442 | ```
443 |
444 | ```{r}
445 | new_m * 20
446 | ```
447 |
448 |
449 | ```{r}
450 | dim(new_m)
451 | new_m[2,3]
452 | ```
453 | ---
454 | # Dataframe
455 |
456 | ## Tabular Structure
457 |
458 | * dimension
459 | * row.names
460 | * col.names
461 |
462 |
463 | ```{r}
464 | colleges <- c("CIT","GCT","PSG")
465 |
466 | year <- c(2019,2018,2017)
467 |
468 | db <- data.frame(college_names = colleges, year_since = year)
469 |
470 | db
471 |
472 |
473 | ```
474 |
475 | ---
476 | # Dataframe Manipulation
477 |
478 | ```{r}
479 | db$college_names
480 | ```
481 |
482 | ```{r}
483 | db[2,2] <- 1990
484 |
485 | db
486 |
487 | ```
488 |
489 | ```{r}
490 | db[,"year_since"]
491 | ```
492 |
493 | ---
494 |
495 | # Loops & Iterators
496 |
497 | ## For Loop
498 |
499 | ```{r}
500 | for (month_name in month.abb[1:4]) {
501 | print(paste("This month", month_name, "beautiful!!!"))
502 | }
503 |
504 | ```
505 |
506 | As you move forward, Check the family of `apply` functions - `sapply()`, `tapply()`, `lapply()`, `apply()`.
507 |
508 | For advanced functional programming, refer `purrr` package
509 |
510 | ---
511 |
512 | # Logical Operations
513 |
514 | ## %in% operator
515 |
516 | ```{r}
517 |
518 | iris$Species %in% "virginica"
519 |
520 | ```
521 |
522 | ---
523 |
524 | ## Logical Operators
525 |
526 | ```{r}
527 | 1:10 > 5
528 | ```
529 |
530 | ```{r}
531 | 1:10 == 4
532 | ```
533 |
534 | ```{r}
535 | !1:10 == 4
536 | ```
537 |
538 | ---
539 | # Conditions
540 |
541 | ```{r}
542 | if (iris$Sepal.Length[2]>5) {
543 | print("it is gt 5")
544 | } else print("it is not")
545 | ```
546 |
547 |
548 | ```{r}
549 | if (iris$Sepal.Length>10) {print("hello")}
550 | ```
551 |
552 | ```{r}
553 | ifelse(iris$Sepal.Length>6, "more_than_10","les_than_10")
554 | ```
555 |
556 | ---
557 |
558 | # Functions
559 |
560 | ## Types
561 |
562 | - Base-R functions (`mean()`, `plot()`, `lm()`)
563 | - Package functions (`dplyr::mutate()`, `stringr::str_detect()`)
564 | - User-defined functions
565 |
566 | ```{r}
567 | workshop_hate_message <- function(name = "No one", n = 3) {
568 | text_to_print <- paste(name, "hate(s)", "this workshop")
569 | for(i in 1:n) {
570 | print(text_to_print)
571 | }
572 |
573 | }
574 |
575 | workshop_hate_message("All of us",4)
576 | ```
577 |
578 |
579 | ---
580 |
581 | # Packages
582 |
583 | ## Package Installation & Loading
584 |
585 | ### From CRAN (usually Stable Version)
586 |
587 | ```{r eval=FALSE}
588 | install.packages("itunesr")
589 | ```
590 |
591 | **From Github (usually Development Version)**
592 |
593 | ```{r eval=FALSE}
594 | #install.packages("devtools")
595 | devtools::install_github("amrrs/itunesr")
596 | ```
597 |
598 | ### Loading
599 |
600 | ```{r eval=FALSE}
601 | library(itunesr)
602 | ```
603 |
604 | ---
605 |
606 | # Help
607 |
608 | ## using `help()`
609 |
610 | ```{r eval=FALSE}
611 | help("runif")
612 | ```
613 |
614 | ## using ?
615 |
616 | ```{r eval=FALSE}
617 | ?sample
618 | ```
619 |
620 | ---
621 |
622 | # Help - Example
623 |
624 | ```{r}
625 | example("for")
626 | ```
627 |
628 | ---
629 |
630 | # Packages Vignette
631 |
632 | ```{r eval=FALSE}
633 | vignette("dplyr")
634 |
635 | browseVignettes("dplyr")
636 | ```
637 |
638 |
639 |
640 | ---
641 | class: inverse, center, middle
642 |
643 | # Data wrangling and Visualization using Tidyverse
644 |
645 | ---
646 | class: center, middle
647 |
648 | # Data Science Framework
649 |
650 |
651 | There are now like, you know, a billion venn diagrams showing you what data science is. But to me I think the definition is pretty simple. Whenever you're struggling with data, trying to understand what's going on with data, whenever you're trying to turn that **raw data into insight and understanding and discoveries**. I think that's **Data Science.**" - Hadley Wickham
652 |
653 |
654 |
656 | Source: Hadley Wickham
657 |
658 |
659 |
660 |
661 | ---
662 |
663 | # Tidyverse
664 |
665 |
666 | - An opinionated collection of R packages designed for data science.
667 | - All packages share an underlying design *philosophy, grammar, and data structures*.
668 |
669 | ```{r eval=FALSE}
670 | install.packages("tidyverse")
671 | ```
672 |
673 | ### tidyverse packages
674 |
675 | ```{r}
676 | tidyverse::tidyverse_packages()
677 | ```
678 |
679 | ---
680 |
681 | # Loading the Library
682 |
683 | ```{r}
684 |
685 | library(tidyverse)
686 |
687 | ```
688 |
689 |
690 | ---
691 |
692 | # Input Data
693 |
694 | Reading the dataset
695 |
696 | ```{r warning=FALSE, message=FALSE}
697 |
698 | #kaggle <- read_csv("data/kaggle_survey_2018.csv")
699 |
700 | kaggle <- read_csv("data/kaggle_survey_2018.csv", skip = 1)
701 | ```
702 |
703 | ---
704 |
705 | # Basic Stats
706 |
707 | ### Dimension (Rows Column)
708 |
709 | ```{r}
710 |
711 | dim(kaggle)
712 | ```
713 |
714 | ```{r}
715 | glimpse(kaggle)
716 | ```
717 |
718 | ---
719 |
720 | class: inverse, center
721 |
722 | # Dataset Overview
723 | ## Demo on RStudio
724 |
725 | ---
726 |
727 | # Data Questions (Business Problem)
728 |
729 | - What's the percentage of Male and Female respondents?
730 |
731 | - What are the top 5 countries?
732 |
733 | ---
734 |
735 | # dyplr verbs
736 |
737 | - `mutate()` - adds new variables that are functions of existing variables
738 | - `select()` - picks variables based on their names.
739 | - `filter()` - picks cases based on their values.
740 | - `summarise()` - reduces multiple values down to a single summary.
741 | - `arrange()` - changes the ordering of the rows.
742 |
743 | ---
744 |
745 | # Introducing %>% Pipe Operator
746 |
747 | - The pipe, `%>%`, comes from the magrittr package by Stefan Milton Bache
748 |
749 | - **Output of LHS** is given as the **input (first argument) of RHS**
750 |
751 | ### Example
752 |
753 | ```{r}
754 |
755 | kaggle %>% dim()
756 |
757 | ```
758 |
759 | Although doesn't make much sense to use `%>%` in this context, Hope it explains the function.
760 |
761 | ---
762 |
763 | # Percentage of Male and Female
764 |
765 | * Column name - `What is your gender? - Selected Choice`
766 |
767 | ### Pseudo-code
768 |
769 | - `group_by` the `kaggle` dataframe on column `What is your gender? - Selected Choice`
770 | - `count` the values
771 | - calculate `percentage` value from the `count`s
772 |
773 | ---
774 |
775 | # % of Male and Female - Group By & Count - Method 1
776 |
777 |
778 | ```{r}
779 | kaggle %>%
780 | group_by(`What is your gender? - Selected Choice`) %>%
781 | summarise(n = n())
782 | ```
783 |
784 | ---
785 |
786 | # % of Male and Female - Group By & Count - Method 2
787 |
788 | ```{r}
789 | kaggle %>%
790 | group_by(`What is your gender? - Selected Choice`) %>%
791 | count()
792 | ```
793 |
794 | ---
795 |
796 | # % of Male and Female - Group By & Count - Sorted
797 |
798 | ```{r}
799 | kaggle %>%
800 | group_by(`What is your gender? - Selected Choice`) %>%
801 | count() %>%
802 | arrange(desc(n))
803 | ```
804 |
805 |
806 | ---
807 |
808 | # % of Male and Female - Percentage
809 |
810 |
811 | ```{r}
812 | kaggle %>%
813 | group_by(`What is your gender? - Selected Choice`) %>%
814 | count() %>%
815 | ungroup() %>%
816 | mutate(perc = round(n / sum(n),2))
817 | ```
818 |
819 | ---
820 |
821 | # % of Male and Female - Nice_Looking_Table
822 |
823 |
824 | ```{r}
825 | kaggle %>%
826 | group_by(`What is your gender? - Selected Choice`) %>%
827 | count() %>%
828 | ungroup() %>%
829 | mutate(perc = round(n / sum(n),2)) %>%
830 | knitr::kable(format = "html")
831 | ```
832 |
833 | ---
834 |
835 | class: inverse,center,middle
836 |
837 | # But, Wait!!!
838 | ## Go Back and See
839 | ### If you have only `Male` and `Female`?
840 |
841 |
842 | ---
843 |
844 | class: inverse,center,middle
845 |
846 | # Time for some cleaning
847 | ## In the form of `filter()`ing
848 |
849 | ---
850 |
851 | # % of Male and Female - Filtered_Nice
852 |
853 |
854 | ```{r}
855 | kaggle %>%
856 | filter(`What is your gender? - Selected Choice` %in% c("Male","Female")) %>%
857 | group_by(`What is your gender? - Selected Choice`) %>%
858 | count() %>%
859 | ungroup() %>%
860 | mutate(perc = round(n / sum(n),2)) %>%
861 | knitr::kable(format = "html")
862 | ```
863 |
864 |
865 | ---
866 |
867 | class: inverse,center,middle
868 |
869 | # An Awkward column name, isn't it??!
870 |
871 | ---
872 |
873 | # % of Male and Female - All_Nice_Table
874 |
875 | ```{r}
876 | library(scales) #for Percentage Formatting
877 |
878 | kaggle %>%
879 | filter(`What is your gender? - Selected Choice` %in% c("Male","Female")) %>%
880 | group_by(`What is your gender? - Selected Choice`) %>%
881 | count() %>%
882 | ungroup() %>%
883 | mutate(perc = round(n / sum(n),2)) %>%
884 | mutate(perc = scales::percent(perc)) %>%
885 | rename(Gender = `What is your gender? - Selected Choice`,
886 | Count = n,
887 | Percentage = perc) %>%
888 | knitr::kable(format = "html")
889 | ```
890 |
891 | ---
892 |
893 | # Top 5 Countries
894 |
895 | * Column name - `In which country do you currently reside?`
896 |
897 |
898 | ### Pseudo-code
899 |
900 | - `count` number of respondents from each country
901 | - `arrange` countries in descending order based on their count value
902 | - `top 5` in the list is the output
903 |
904 | ---
905 |
906 | # Top 5 Countries - Code
907 |
908 | ```{r}
909 | kaggle %>%
910 | count(`In which country do you currently reside?`) %>%
911 | arrange(desc(n)) %>%
912 | top_n(5) %>%
913 | knitr::kable(format = "html")
914 | ```
915 |
916 |
917 | ---
918 | class: inverse,center,middle
919 |
920 | # Is `Other` a country name???
921 |
922 | ---
923 |
924 | # Top 5 Countries
925 |
926 | ```{r}
927 | kaggle %>%
928 | filter(!`In which country do you currently reside?` %in% "Other") %>%
929 | count(`In which country do you currently reside?`) %>%
930 | rename(Country = `In which country do you currently reside?`) %>%
931 | arrange(desc(n)) %>%
932 | top_n(5) %>%
933 | knitr::kable(format = "html")
934 | ```
935 |
936 |
937 | ---
938 | class: inverse,center,middle
939 |
940 | # Table is nice, but a visually appealing plot is Nicer
941 | ## 😉
942 |
943 |
944 | ---
945 |
946 | # Top 5 Countries - Plot #1
947 |
948 | ```{r countries1, eval = FALSE}
949 | kaggle %>%
950 | filter(!`In which country do you currently reside?` %in% "Other") %>%
951 | count(`In which country do you currently reside?`) %>%
952 | rename(Country = `In which country do you currently reside?`) %>%
953 | arrange(desc(n)) %>%
954 | top_n(5) %>%
955 | ggplot() + geom_bar(aes(Country,n), stat = "identity") +
956 | coord_flip() +
957 | theme_minimal() +
958 | labs(title = "Top 5 Countries",
959 | subtitle = "From where Kaggle Survey Respondentns reside",
960 | x = "Country",
961 | y = "Number of Respondents",
962 | caption = "Data Source: Kaggle Survey 2018")
963 | ```
964 |
965 | ---
966 |
967 | # Top 5 Countries - Plot #2
968 |
969 | ```{r countries2, echo=FALSE, message=FALSE, warning=FALSE}
970 | kaggle %>%
971 | filter(!`In which country do you currently reside?` %in% "Other") %>%
972 | count(`In which country do you currently reside?`) %>%
973 | rename(Country = `In which country do you currently reside?`) %>%
974 | arrange(desc(n)) %>%
975 | top_n(5) %>%
976 | ggplot() + geom_bar(aes(Country,n), stat = "identity") +
977 | coord_flip() +
978 | theme_minimal() +
979 | labs(title = "Top 5 Countries",
980 | subtitle = "From where Kaggle Survey Respondents reside",
981 | x = "Country",
982 | y = "Number of Respondents",
983 | caption = "Data Source: Kaggle Survey 2018")
984 | ```
985 |
986 | ---
987 |
988 | # Top 5 Countries - Plot #3 Themed
989 |
990 | ```{r countries3, echo=FALSE, message=FALSE, warning=FALSE, fig.width= 10}
991 | library(ggthemes)
992 |
993 | kaggle %>%
994 | filter(!`In which country do you currently reside?` %in% "Other") %>%
995 | count(`In which country do you currently reside?`) %>%
996 | rename(Country = `In which country do you currently reside?`) %>%
997 | arrange(desc(n)) %>%
998 | top_n(5) %>%
999 | ggplot() + geom_bar(aes(Country,n), stat = "identity") +
1000 | # coord_flip() +
1001 | theme_minimal() +
1002 | labs(title = "Top 5 Countries",
1003 | subtitle = "From where Kaggle Survey Respondents reside",
1004 | x = "Country",
1005 | y = "Number of Respondents",
1006 | caption = "Data Source: Kaggle Survey 2018") +
1007 | ggthemes::theme_wsj()
1008 | ```
1009 |
1010 |
1011 | ---
1012 |
1013 | class: inverse, center, middle
1014 |
1015 | # Documentation and Reporting using R Markdown
1016 | ## Demo
1017 |
1018 | ---
1019 |
1020 | class: inverse, center, middle
1021 |
1022 | # Project Demo
1023 |
1024 | ---
1025 |
1026 |
1027 | class: center, middle
1028 |
1029 | # Object Detection in 3 Lines of R Code
1030 | ## using Tiny YOLO
1031 | ### -Project Demo-
1032 |
1033 | ---
1034 |
1035 |
1036 | # References
1037 |
1038 |
1039 | - [R for Data Science](https://r4ds.had.co.nz/)
1040 |
1041 | - [R-Bloggers](https://www.r-bloggers.com/)
1042 |
1043 | ---
1044 |
1045 | class: center, middle
1046 |
1047 | # Thanks!
1048 |
1049 | Slides created via the R package [**xaringan**](https://github.com/yihui/xaringan).
1050 |
1051 | The chakra comes from [remark.js](https://remarkjs.com), [**knitr**](http://yihui.name/knitr), and [R Markdown](https://rmarkdown.rstudio.com).
1052 |
1053 |
--------------------------------------------------------------------------------
/presentation.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amrrs/r_beginners_workshop/1971ded361f43811a542583a43a0e82fd256642e/presentation.pdf
--------------------------------------------------------------------------------
/presentation_files/figure-html/countries2 -1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amrrs/r_beginners_workshop/1971ded361f43811a542583a43a0e82fd256642e/presentation_files/figure-html/countries2 -1.png
--------------------------------------------------------------------------------
/presentation_files/figure-html/countries2-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amrrs/r_beginners_workshop/1971ded361f43811a542583a43a0e82fd256642e/presentation_files/figure-html/countries2-1.png
--------------------------------------------------------------------------------
/presentation_files/figure-html/countries3 -1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amrrs/r_beginners_workshop/1971ded361f43811a542583a43a0e82fd256642e/presentation_files/figure-html/countries3 -1.png
--------------------------------------------------------------------------------
/presentation_files/figure-html/countries3-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amrrs/r_beginners_workshop/1971ded361f43811a542583a43a0e82fd256642e/presentation_files/figure-html/countries3-1.png
--------------------------------------------------------------------------------
/presentation_files/figure-html/iechoFALSE-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amrrs/r_beginners_workshop/1971ded361f43811a542583a43a0e82fd256642e/presentation_files/figure-html/iechoFALSE-1.png
--------------------------------------------------------------------------------
/projects/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amrrs/r_beginners_workshop/1971ded361f43811a542583a43a0e82fd256642e/projects/.DS_Store
--------------------------------------------------------------------------------
/projects/Object_Detection_in_R/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/projects/Object_Detection_in_R/README.md:
--------------------------------------------------------------------------------
1 | # TinyYOLO in R
2 |
3 | Image Detection in R using `image.darknet` and Tiny YOLO
4 |
5 | # Input
6 |
7 | 
8 |
9 | # References:
10 |
11 | * Project Link - [https://github.com/amrrs/tinyyolo_in_R](https://github.com/amrrs/tinyyolo_in_R)
12 | * Blogpost - [Object detection in just 3 lines of R code using Tiny YOLO](https://heartbeat.fritz.ai/object-detection-in-just-3-lines-of-r-code-using-tiny-yolo-b5a16e50e8a0)
13 |
14 |
--------------------------------------------------------------------------------
/projects/Object_Detection_in_R/google-car.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amrrs/r_beginners_workshop/1971ded361f43811a542583a43a0e82fd256642e/projects/Object_Detection_in_R/google-car.png
--------------------------------------------------------------------------------
/projects/Object_Detection_in_R/tinyyolo_3_lines_in_R.R:
--------------------------------------------------------------------------------
1 | #devtools::install_github("bnosac/image", subdir = "image.darknet", build_vignettes = TRUE)
2 |
3 | library(image.darknet)
4 |
5 | #If required, Set new working directory where the final predictions imaged with bounding box will be saved
6 |
7 | setwd(paste0(getwd(),"/projects/"))
8 |
9 | #Define Model - here it is Tiny Yolo
10 | yolo_tiny_voc <- image_darknet_model(type = 'detect',
11 | model = "tiny-yolo-voc.cfg",
12 | weights = system.file(package="image.darknet", "models", "tiny-yolo-voc.weights"),
13 | labels = system.file(package="image.darknet", "include", "darknet", "data", "voc.names"))
14 |
15 |
16 |
17 | #Image Detection
18 | x <- image_darknet_detect(file = "Object_Detection_in_R/google-car.png",
19 | object = yolo_tiny_voc,
20 | threshold = 0.19)
21 |
--------------------------------------------------------------------------------
/r_beginners_workshop.Rproj:
--------------------------------------------------------------------------------
1 | Version: 1.0
2 |
3 | RestoreWorkspace: Default
4 | SaveWorkspace: Default
5 | AlwaysSaveHistory: Default
6 |
7 | EnableCodeIndexing: Yes
8 | UseSpacesForTab: Yes
9 | NumSpacesForTab: 2
10 | Encoding: UTF-8
11 |
12 | RnwWeave: Sweave
13 | LaTeX: pdfLaTeX
14 |
--------------------------------------------------------------------------------