class: center, middle, inverse, title-slide # Data Science for Economists ## Lecture 4: R language basics ### Grant McDermott ### University of Oregon |
EC 607
--- name: toc  # Table of contents 1. [Prologue](#prologue) 2. [Introduction](#intro) 3. [Object-oriented programming in R](#oop) 4. ["Everything is an object"](#eobject) 5. ["Everything has a name"](#ename) 6. [Indexing](#indexing) 7. [Cleaning up](#cleaning) --- class: inverse, center, middle name: prologue # Prologue

 --- # Checklist ☑ Pull from the lecture repo to get the latest slides. ☑ Did everyone manage to try the simple shell exercises at the back of our last lecture? ☑ Update your R packages. Do this regularly as a matter of good habit. -- ### Packages that you will need for today. We're going to work almost exclusively in **base** R today. - I'll also use the [**dplyr**](https://dplyr.tidyverse.org/) package, but only to demonstrate a few additional considerations for working with non-base libraries. Install/update it now, either through RStudio (recommended) or from your R console (`install.packages("dplyr"), dependencies = TRUE`). - (P.S. If you're on Linux, I recommend installing the pre-compiled binary version of **dplyr** from [RSPM](https://packagemanager.rstudio.com/client/#/repos/1/overview). This avoids the need to build the package from source, greatly reducing your installation time. See related example [here](https://twitter.com/grant_mcdermott/status/1263951531461603328).) --- # Agenda Today and the next lecture are going to be very hands on. - I'll have slides as per usual, but we're going to spent a lot of time live coding together. This is deliberate. - I want you to get comfortable typing R commands yourself — and navigating the RStudio IDE — without resorting to copy+paste. - Slightly more painful in the beginning, but much better payoff in the long-run. --- class: inverse, center, middle name: intro # Introduction

 (Some important R concepts) --- # Basic arithmetic R is a powerful calculator and recognizes all of the standard arithmetic operators: ```r 1+2 ## Addition ``` ``` ## [1] 3 ``` ```r 6-7 ## Subtraction ``` ``` ## [1] -1 ``` ```r 5/2 ## Division ``` ``` ## [1] 2.5 ``` ```r 2^3 ## Exponentiation ``` ``` ## [1] 8 ``` ```r 2+4*1^3 ## Standard order of precedence (`*` before `+`, etc.) ``` ``` ## [1] 6 ``` --- # Basic arithmetic (cont.) We can also invoke modulo operators (integer division & remainder). - Very useful when dealing with time, for example. ```r 100 %/% 60 ## How many whole hours in 100 minutes? ``` ``` ## [1] 1 ``` ```r 100 %% 60 ## How many minutes are left over? ``` ``` ## [1] 40 ``` --- # Logic R also comes equipped with a full set of logical operators and Booleans, which follow standard programming protocol. For example: ```r 1 > 2 ``` ``` ## [1] FALSE ``` ```r 1 > 2 & 1 > 0.5 ## The "&" stands for "and" ``` ``` ## [1] FALSE ``` ```r 1 > 2 | 1 > 0.5 ## The "|" stands for "or" (not a pipe a la the shell) ``` ``` ## [1] TRUE ``` ```r isTRUE (1 < 2) ``` ``` ## [1] TRUE ``` -- You can read more about logical operators and types here and here. In the next few slides, however, I want to emphasise some special concepts and gotchas... --- # Logic (cont.) ### Order of precedence Much like standard arithmetic, logic statements follow a strict order of precedence. Logical operators (`>`, `==`, etc) are evaluated before Boolean operators (`&` and `|`). Failure to recognise this can lead to unexpected behaviour... ```r 1 > 0.5 & 2 ``` ``` ## [1] TRUE ``` -- What's happening here is that R is evaluating two separate "logical" statements: - `1 > 0.5`, which is is obviously TRUE. - `2`, which is TRUE(!) because R is "helpfully" converting it to `as.logical(2)`. -- **Solution:** Be explicit about each component of your logic statement(s). ```r 1 > 0.5 & 1 > 2 ``` ``` ## [1] FALSE ``` --- # Logic (cont.) ### Negation: `!` We use `!` as a short hand for negation. This will come in very handy when we start filtering data objects based on non-missing (i.e. non-NA) observations. ```r is.na(1:10) ``` ``` ## [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE ``` ```r !is.na(1:10) ``` ``` ## [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE ``` ```r # Negate(is.na)(1:10) ## This also works. Try it yourself. ``` --- # Logical operators (cont.) ### Value matching: `%in%` To see whether an object is contained within (i.e. matches one of) a list of items, use `%in%`. ```r 4 %in% 1:10 ``` ``` ## [1] TRUE ``` ```r 4 %in% 5:10 ``` ``` ## [1] FALSE ``` -- There's no equivalent "not in" command, but how might we go about creating one? - Hint: Think about negation... -- ```r `%ni%` = Negate(`%in%`) ## The backticks (`) help to specify functions. 4 %ni% 5:10 ``` ``` ## [1] TRUE ``` --- # Logical operators (cont.) ### Evaluation We'll get to assignment shortly. However, to preempt it somewhat, we always use two equal signs for logical evaluation. ```r 1 = 1 ## This doesn't work ``` ``` ## Error in 1 = 1: invalid (do_set) left-hand side to assignment ``` ```r 1 == 1 ## This does. ``` ``` ## [1] TRUE ``` ```r 1 != 2 ## Note the single equal sign when combined with a negation. ``` ``` ## [1] TRUE ``` --- # Logical operators (cont.) ### Evaluation caveat: Floating-point numbers What do you think will happen if we evaluate `0.1 + 0.2 == 0.3`? -- ```r 0.1 + 0.2 == 0.3 ``` ``` ## [1] FALSE ``` Uh-oh! (Or, maybe you're thinking: Huh??) -- **Problem:** Computers represent numbers as binary (i.e. base 2) floating-points. More [here](https://floating-point-gui.de/basic/). - Fast and memory efficient, but can lead to unexpected behaviour. - Similar to the way that standard decimal (i.e. base 10) representation can't precisely capture certain fractions (e.g. `\(\frac{1}{3} = 0.3333...\)`). -- **Solution:** Use `all.equal()` for evaluating floats (i.e fractions). ```r all.equal(0.1 + 0.2, 0.3) ``` ``` ## [1] TRUE ``` --- # Assignment In R, we can use either `<-` or `=` to handle assignment.1 .footnote[ 1 The `<-` is really a `<` followed by a `-`. It just looks like one thing b/c of the [font](https://github.com/tonsky/FiraCode) I'm using here. ] -- ### Assignment with `<-` `<-` is normally read aloud as "gets". You can think of it as a (left-facing) arrow saying *assign in this direction*. ```r a <- 10 + 5 a ``` ``` ## [1] 15 ``` -- Of course, an arrow can point in the other direction too (i.e. `->`). So, the following code chunk is equivalent to the previous one, although used much less frequently. ```r 10 + 5 -> a ``` --- # Assignment (cont.) ### Assignment with `=` You can also use `=` for assignment. ```r b = 10 + 10 ## Note that the assigned object *must* be on the left with "=". b ``` ``` ## [1] 20 ``` -- ### Which assignment operator to use? Most R users (purists?) seem to prefer `<-` for assignment, since `=` also has specific role for evaluation *within* functions. - We'll see lots of examples of this later. - But I don't think it matters; `=` is quicker to type and is more intuitive if you're coming from another programming language. (More discussion [here](https://github.com/Robinlovelace/geocompr/issues/319#issuecomment-427376764) and [here](https://www.separatinghyperplanes.com/2018/02/why-you-should-use-and-never.html).) **Bottom line:** Use whichever you prefer. Just be consistent. --- # Help For more information on a (named) function or object in R, consult the "help" documentation. For example: ```R help(plot) ``` Or, more simply, just use `?`: ```R # This is what most people use. ?plot ``` --
 **Aside 1:** Comments in R are demarcated by `#`. - Hit `Ctrl+Shift+c` in RStudio to (un)comment whole sections of highlighted code. -- **Aside 2:** See the *Examples* section at the bottom of the help file? - You can run them with the `example()` function. Try it: `example(plot)`. --- # Help (cont.) ### Vignettes For many packages, you can also try the `vignette()` function, which will provide an introduction to a package and it's purpose through a series of helpful examples. - Try running `vignette("dplyr")` in your console now. -- I highly encourage reading package vignettes if they are available. - They are often the best way to learn how to use a package. -- One complication is that you need to know the exact name of the package vignette(s). - E.g. The `dplyr` package actually has several vignettes associated with it: "dplyr", "window-functions", "programming", etc. - You can run `vignette()` (i.e. without any arguments) to list the available vignettes of every *installed* package installed on your system. - Or, run `vignette(all = FALSE)` if you only want to see the vignettes of any *loaded* packages. --- # Help (cont.) ### Demos Similar to vignettes, many packages come with built-in, interactive demos. To list all available demos on your system:1 ```r demo(package = .packages(all.available = TRUE)) ``` .footnote[ 1 How would you limit the demos to one particular package? ] -- To run a specific demo, just tell R which one and the name of the parent package. For example: ```r demo("graphics", package = "graphics") ``` --- class: inverse, center, middle name: oop # Object-oriented programming in R

 --- # Motivation In our very first lecture, I mentioned R's approach to [object-oriented programming](https://en.wikipedia.org/wiki/Object-oriented_programming) (OOP), which is often summarised as: > **"Everything is an object and everything has a name."** -- In the next two sections, I want to dive into this idea a little more. I also want to preempt some issues that might trip you up if you new to R or OOP in general. - At least, they were things that tripped me up at the beginning. -- The good news, as well see, is that avoiding and solving these issues is pretty straightforward. - Not to mention: A very small price to pay for the freedom and control that R offers us. --- # Disclaimer Okay, this slide is just to let you know that I'm being a little fast and loose with terms. Most obviously, there are actually _multiple_ OOP frameworks in R. - **S3**, **S4**, **R6**... - Hadley Wickham's "Advanced R" provides a [very thorough overview](https://adv-r.hadley.nz/oo.html) of the main ones. But for our purposes, I think it is much more helpful to think about (a) the shared characteristics of these different systems and (b) the broad implications of OOP in R. - What we lose in detail, we hopefully gain in perspective. - But do read Hadley's book if you get the chance. It's incredibly helpful (as are all his books). --- class: inverse, center, middle name: eobject # "Everything is an object"

 --- # What are objects? It's important to emphasise that there are many different *types* (or *classes*) of objects. We'll revisit the issue of "type" vs "class" in a slide or two. For the moment, it is helpful simply to name some objects that we'll be working with regularly: - vectors - matrices - data frames - lists - functions - etc. -- Most likely, you already have a good idea of what distinguishes these objects and how to use them. - However, bear in mind that there subtleties that may confuse while you're still getting used to R. - E.g. There are different kinds of data frames. We'll soon encounter "[tibbles](https://tibble.tidyverse.org/)" and "[data.tables](https://rdatatable.gitlab.io/data.table/articles/datatable-intro.html#what-is-datatable-1a)", which are enhanced versions of the standard data frame in R. --- # What are objects? (cont.) Each object class has its own set of rules ("methods") for determining valid operations. - For example, you can perform many of the same operations on matrices and data frames. But there are some operations that only work on a matrix, and vice versa. - At the same time, you can (usually) convert an object from one type to another. ```r ## Create a small data frame called "d". d = data.frame(x = 1:2, y = 3:4) d ``` ``` ## x y ## 1 1 3 ## 2 2 4 ``` ```r ## Convert it to (i.e. create) a matrix call "m". m = as.matrix(d) m ``` ``` ## x y ## [1,] 1 3 ## [2,] 2 4 ``` --- # Object class, type, and structure Use the `class`, `typeof`, and `str` commands if you want understand more about a particular object. ```r # d = data.frame(x = 1:2, y = 3:4) ## Create a small data frame called "d". class(d) ## Evaluate its class. ``` ``` ## [1] "data.frame" ``` ```r typeof(d) ## Evaluate its type. ``` ``` ## [1] "list" ``` ```r str(d) ## Show its structure. ``` ``` ## 'data.frame': 2 obs. of 2 variables: ## $ x: int 1 2 ## $ y: int 3 4 ``` -- PS — Confused by the fact that `typeof(d)` returns "list"? See [here](https://stackoverflow.com/questions/45396538/typeofdata-frame-shows-list-in-r). --- # Object class, type, and structure (cont.) Of course, you can always just inspect/print an object directly in the console. - E.g. Type `d` and hit Enter. The `View()` function is also very helpful. This is the same as clicking on the object in your RStudio *Environment* pane. (Try both methods now.) - E.g. `View(d)`. --- name: global_env # Global environment Let's go back to the simple data frame that we created a few slides earlier. ```r d ``` ``` ## x y ## 1 1 3 ## 2 2 4 ``` -- Now, let's try to run a regression1 on these "x" and "y" variables: .footnote[ 1 Yes, this is a dumb regression with perfectly co-linear variables. Just go with it. ] ```r lm(y ~ x) ## The "lm" stands for linear model(s) ``` ``` ## Error in eval(predvars, data, env): object 'y' not found ``` -- Uh-oh. What went wrong here? (Answer on next slide.) --- # Global environment (cont.) The error message provides the answer to our question: ``` *## Error in eval(predvars, data, env): object 'y' not found ``` -- R can't find the variables that we've supplied in our [Global Environment](https://www.datamentor.io/r-programming/environment-scope/): ![No "x" or "y" here...](pics/environment.png) -- Put differently: Because the variables "x" and "y" live as separate objects in the global environment, we have to tell R that they belong to the object `d`. - Think about how you might do this before clicking through to the next slide. --- # Global environment (cont.) There are a various ways to solve this problem. One is to simply specify the datasource: ```r lm(y ~ x, data = d) ## Works when we add "data = d"! ``` ``` ## ## Call: ## lm(formula = y ~ x, data = d) ## ## Coefficients: ## (Intercept) x ## 2 1 ``` -- I wanted to emphasize this global environment issue, because it is something that Stata users (i.e. many economists) struggle with when they first come to R. - In Stata, the entire workspace essentially consists of one (and only one) data frame. So there can be no ambiguity where variables are coming from. - However, that "convenience" comes at a really high price IMO. You can never read more than two separate datasets (let alone object types) into memory at the same time, have to resort all sorts of hacks to add summary variables to your dataset, etc. - Speaking of which... --- # Working with multiple objects As I keep saying, R's ability to keep multiple objects in memory at the same time is a huge plus when it comes to effective data work. - E.g. We can copy an exiting data frame, or create new one entirely from scratch. Either will exist happily with our existing objects in the global environment. ```r d2 = data.frame(x = rnorm(10), y = runif(10)) ``` ![Now with d2 added](pics/environment2.png) --- # Working with multiple objects (cont.) Again, however, it does mean that you have to pay attention to the names of those distinct data frames and be specific about which objects you are referring to. - Do we want to run a regression of "y" on "x" from data frame `d` or data frame `d2`? --- class: inverse, center, middle name: ename # "Everything has a name"

 --- # Reserved words We've seen that we can assign objects to different names. However, there are a number of special words that are "reserved" in R. - These are are fundamental commands, operators and relations in base R that you cannot (re)assign, even if you wanted to. - We already encountered examples with the logical operators. See [here](http://stat.ethz.ch/R-manual/R-devel/library/base/html/Reserved.html) for a full list, including (but not limited to): ```R if else while function for TRUE FALSE NULL Inf NaN NA ``` --- # Semi-reserved words In addition to the list of strictly reserved words, there is a class of words and strings that I am going to call "semi-reserved". - These are named functions or constants (e.g. `pi`) that you can re-assign if you really wanted to... but already come with important meanings from base R. Arguably the most important semi-reserved character is `c()`, which we use for concatenation; i.e. creating vectors and binding different objects together. ```r my_vector = c(1, 2, 5) my_vector ``` ``` ## [1] 1 2 5 ``` -- What happens if you type the following? (Try it in your console.) ```R c = 4 c(1, 2 ,5) ``` ??? Vectors are very important in R, because the language has been optimised for them. Don't worry about this now; later you'll learn what I mean by "vectorising" a function. --- # Semi-reserved words (cont.) *(Continued from previous slide.)* In this case, thankfully nothing. R is "smart" enough to distinguish between the variable `c = 4` that we created and the built-in function `c()` that calls for concatenation. -- However, this is still *extremely* sloppy coding. R won't always be able to distinguish between conflicting definitions. And neither will you. For example: ```r pi ``` ``` ## [1] 3.141593 ``` ```r pi = 2 pi ``` ``` ## [1] 2 ``` -- **Bottom line:** Don't use (semi-)reserved characters! --- # Namespace conflicts A similar issue crops up when we load two packages, which have functions that share the same name. E.g. Look what happens we load the `dplyr` package. ```r library(dplyr) ``` ``` ## ## Attaching package: 'dplyr' ``` ``` ## The following objects are masked from 'package:stats': ## ## filter, lag ``` ``` ## The following objects are masked from 'package:base': ## ## intersect, setdiff, setequal, union ``` -- The messages that you see about some object being *masked from 'package:X'* are warning you about a namespace conflict. - E.g. Both `dplyr` and the `stats` package (which gets loaded automatically when you start R) have functions named "filter" and "lag". --- # Namespace conflicts (cont.) The potential for namespace conflicts is a result of the OOP approach.1 - Also reflects the fundamental open-source nature of R and the use of external packages. People are free to call their functions whatever they want, so some overlap is only to be expected. .footnote[ 1 Similar problems arise in virtually every other programming language (Python, C, etc.) ] -- Whenever a namespace conflict arises, the most recently loaded package will gain preference. So the `filter()` function now refers specifically to the `dplyr` variant. But what if we want the `stats` variant? Well, we have two options: 1. Temporarily use `stats::filter()` 2. Permanently assign `filter = stats::filter` --- # Solving namespace conflicts ### 1. Use `package::function()` We can explicitly call a conflicted function from a particular package using the `package::function()` syntax. For example: ```r stats::filter(1:10, rep(1, 2)) ``` ``` ## Time Series: ## Start = 1 ## End = 10 ## Frequency = 1 ## [1] 3 5 7 9 11 13 15 17 19 NA ``` -- We can also use `::` for more than just conflicted cases. - E.g. Being explicit about where a function (or dataset) comes from can help add clarity to our code. Try these lines of code in your R console. ```R dplyr::starwars ## Print the starwars data frame from the dplyr package scales::comma(c(1000, 1000000)) ## Use the comma function, which comes from the scales package ``` ??? The `::` syntax also means that we can call functions without loading package first. E.g. As long as `dplyr` is installed on our system, then `dplyr::filter(iris, Species=="virginica")` will work. --- # Solving namespace conflicts (cont.) ### 2. Assign `function = package::function` A more permanent solution is to assign a conflicted function name to a particular package. This will hold for the remainder of your current R session, or until you change it back. E.g. ```r filter = stats::filter ## Note the lack of parentheses. filter = dplyr::filter ## Change it back again. ``` -- ### General advice I would generally advocate for the temporary `package::function()` solution. Another good rule of thumb is that you want to load your most important packages last. (E.g. Load the tidyverse after you've already loaded any other packages.) Other than that, simply pay attention to any warnings when loading a new package and `?` is your friend if you're ever unsure. (E.g. `?filter` will tell you which variant is being used.) - In truth, problematic namespace conflicts are rare. But it's good to be aware of them. --- # User-side namespace conflicts A final thing to say about namespace conflicts is that they don't only arise from loading packages. They can arise when users create their own functions with a conflicting name. - E.g. If I was naive enough to create a new function called `c()`. --
 In a similar vein, one of the most common and confusing errors that even experienced R programmers run into is related to the habit of calling objects "df" or "data"... both of which are functions in base R! - See for yourself by typing `?df` or `?data`. Again, R will figure out what you mean if you are clear/lucky enough. But, much the same as with `c()`, it's relatively easy to run into problems. - Case in point: Triggering the infamous "object of type closure is not subsettable" error message. (See from 1:45 [here](https://rstudio.com/resources/rstudioconf-2020/object-of-type-closure-is-not-subsettable/).) --- class: inverse, center, middle name: indexing # Indexing

 --- # Option 1: [] We've already seen an example of indexing in the form of R console output. For example: ```r 1+2 ``` ``` ## [1] 3 ``` The `[1]` above denotes the first (and, in this case, only) element of our output.1 In this case, a vector of length one equal to the value "3". -- Try the following in your console to see a more explicit example of indexed output: ```r rnorm(n = 100, mean = 0, sd = 1) # rnorm(100) ## Would work just as well. (Why? Hint: see ?rnorm) ``` .footnote[ [1] Indexing in R begins at 1. Not 0 like some languages (e.g. Python and JavaScript). ] --- # Option 1: [] (cont.) More importantly, we can also use `[]` to index objects that we create in R. ```r a = 1:10 a[4] ## Get the 4th element of object "a" ``` ``` ## [1] 4 ``` ```r a[c(4, 6)] ## Get the 4th and 6th elements ``` ``` ## [1] 4 6 ``` It also works on larger arrays (vectors, matrices, data frames, and lists). For example: ```r starwars[1, 1] ## Show the cell corresponding to the 1st row & 1st column of the data frame. ``` ``` ## # A tibble: 1 x 1 ## name ## <chr> ## 1 Luke Skywalker ``` -- What does `starwars[1:3, 1]` give you? --- # Option 1: [] (cont.) We haven't covered them properly yet (patience), but **lists** are a more complex type of array object in R. - They can contain a random assortment of objects that don't share the same class, or have the same shape (e.g. rank) or common structure. - E.g. A list can contain a scalar, a string, and a data frame. Or you can have a list of data frames, or even lists of lists. -- The relevance to indexing is that lists require two square brackets `[[]]` to index the parent list item and then the standard `[]` within that parent item. An example might help to illustrate: ```r my_list = list(a = "hello", b = c(1,2,3), c = data.frame(x = 1:5, y = 6:10)) my_list[[1]] ## Return the 1st list object ``` ``` ## [1] "hello" ``` ```r my_list[[2]][3] ## Return the 3rd element of the 2nd list object ``` ``` ## [1] 3 ``` --- # Option 2: $ Lists provide a nice segue to our other indexing operator: `$`. - Let's continue with the `my_list` example from the previous slide. ```r my_list ``` ``` ## $a ## [1] "hello" ## ## $b ## [1] 1 2 3 ## ## $c ## x y ## 1 1 6 ## 2 2 7 ## 3 3 8 ## 4 4 9 ## 5 5 10 ``` --- count: false # Option 2: $ Lists provide a nice segue to our other indexing operator: `$`. - Let's continue with the `my_list` example from the previous slide. ```r my_list ``` ``` *## $a ## [1] "hello" ## *## $b ## [1] 1 2 3 ## *## $c ## x y ## 1 1 6 ## 2 2 7 ## 3 3 8 ## 4 4 9 ## 5 5 10 ``` Notice how our (named) parent list objects are demarcated: "$a", "$b" and "$c". --- # Option 2: $ (cont.) We can call these objects directly by name using the dollar sign, e.g. ```r my_list$a ## Return list object "a" ``` ``` ## [1] "hello" ``` ```r my_list$b[3] ## Return the 3rd element of list object "b" ``` ``` ## [1] 3 ``` ```r my_list$c$x ## Return column "x" of list object "c" ``` ``` ## [1] 1 2 3 4 5 ``` --
 **Aside:** Typing `View(my_list)` (or, equivalently, clicking on the object in RStudio's environment pane) provides a nice interactive window for exploring the nested structure of lists. --- # Option 2: $ (cont.) The `$` form of indexing also works (and in the manner that you probably expect) for other object types in R. In some cases, you can also combine the two index options. - E.g. Get the 1st element of the "name" column from the starwars data frame. ```r starwars$name[1] ``` ``` ## [1] "Luke Skywalker" ``` -- However, note some key differences between the output from this example and that of our previous `starwars[1, 1]` example. What are they? - Hint: Apart from the visual cues, try wrapping each command in `str()`. --- # Option 2: $ (cont.) The last thing that I want to say about `$` is that it provides another way to avoid the "object not found" problem that we ran into with our earlier regression example. ```r lm(y ~ x) ## Doesn't work ``` ``` ## Error in eval(predvars, data, env): object 'y' not found ``` ```r lm(d$y ~ d$x) ## Works! ``` ``` ## ## Call: ## lm(formula = d$y ~ d$x) ## ## Coefficients: ## (Intercept) d$x ## 2 1 ``` --- class: inverse, center, middle name: cleaning # Cleaning up

 --- # Removing objects (and packages) Use `rm()` to remove an object or objects from your working environment. ```r a = "hello" b = "world" rm(a, b) ``` You can also use `rm(list = ls())` to remove all objects in your working environment (except packages), but this is [frowned upon](https://www.tidyverse.org/articles/2017/12/workflow-vs-script/). - Better just to start a new R session. -- Detaching packages is more complicated, because there are so many cross-dependencies (i.e. one package depends on, and might even automatically load, another.) However, you can try, e.g. `detach(package:dplyr)` - Again, better just to restart your R session. --- # Removing plots You can use `dev.off()` to removing any (i.e. all) plots that have been generated during your session. For example, try this in your R console: ```r plot(1:10) dev.off() ``` -- You may also have noticed that RStudio has convenient buttons for clearing your workspace environment and removing (individual) plots. Just look for these icons in the relevant window panels: ![](pics/broom.png?display=inline-block) --- class: inverse, center, middle # Next lecture(s): Data wrangling and cleaning


The first rate rise in a decade was widely expected by markets.
Talks over Britain’s exit from the EU are blocked mainly because of the divorce bill. The EU won’t allow negotiations to move on until an agreement is reached.
As expected, the FOMC voted to maintain the federal funds rate at a range of 1.00% to 1.25% at the November meeting, citing “realized and expected labor market conditions and inflation” as the driving forces behind today's decision.
After a report was published late Wednesday night implicating interim President Temer in a bribery scandal, opposition politicians called for his impeachment or resignation, resulting in Brazilian markets opening starkly down on Wednesday..
Investors remain focused on tensions in Saudi Arabia, as “the market pays more attention to geopolitical risk.”
Stocks fell while the dollar strengthened and Treasuries nudged higher as investors turned their attention to fiscal policy, with tax writers from the House of Representatives expected to hammer out their plan this week.


teleop module
Contains functions for teleop logic.
-
class
teleop.
Teleop
(robot)[source]
Bases: object
-
buttons
()[source]
-
drive
()[source]
Drive the robot directly using a joystick.
-
foc_enabled
= False
-
last_applied_control
= array([0, 0, 0])
-
lift_control
()[source]
-
update_smart_dashboard
()[source]
-
winch_control
(val)[source]


Automated Proctoring
The exam proctoring process is managed through Examity® for all online courses
delivered through World Campus. Examity® is a company that specializes in
proctoring exams for many institutions of higher education. (For all
University Park web-based course sections that have proctored exams, the
management of the proctoring of exams is the responsibility of the
instructor.)
Below are resources guides for getting started with Examity Automated Proctoring for instructors and user guides for
students.
Instructors
Students
We encourage you to point
students to this guide which outlines how best to prepare for the Automated
Proctoring exam.
Considerations from Faculty
Examity has a learning curve. Using it the first time for the most important exam will
cause stress among students. Many students will fail to run the examity software either
because they don't meet the technical requirement or don't read/follow instructions.
Failure to launch Examity happens more often with the automated option because there
is no one to help out. Examity has tech support but I can't imagine how they will do this
with 1000 + students taking the exam in same day. I outline other concerns in the PDF below.
I have
used live proctoring (a person watches them) for my World Campus courses.
What is being offered to us at this time is an automated option. More info
is below. I would just caution that this is one more layer of complexity to
an already complex situation. There are also several system requirements
noted below. Jackie and I are going to experiment with quizzing via Zoom,
a platform all our students are familiar with since we hold our
live class sessions there. We have surveyed our students as well to know
what technology access they have.
Examity System Requirements
- Desktop computer or laptop (not a tablet)
- Working built-in or external webcam and microphone
-
Internet speed must be at least 2 Mbps download and 2 Mbps upload. Determine
Internet speed by running a test at:
speedtest.net
Examity Support
- Available 24 hours/7 days a week.
- Phone:<PHONE_NUMBER>
-
Email:
<EMAIL_ADDRESS>-
Live Chat: Click on the live chat link located at the top and bottom of your
Examity® portal.


Class to store and retrieve the version of Zend Framework.
compareVersion(string $version) : int
string
A version string (e.g. "0.7.1").
int
-1 if the $version is older, 0 if they are the same, and +1 if $version is newer.
getLatest(string $service = self::VERSION_SERVICE_ZEND) : string
By Default, this uses the GitHub API (v3) and only returns refs that begin with 'tags/release-'. Because GitHub returns the refs in alphabetical order, we need to reduce the array to a single value, comparing the version numbers with version_compare().
If $service is set to VERSION_SERVICE_ZEND this will fall back to calling the classic style of version retreival.
| see | |
|---|---|
| link |
https://api.github.com/repos/zendframework/zf2/git/refs/tags/release- http://framework.zend.com/api/zf-version?v=2 |
string
Version Service with which to retrieve the version
string
isLatest() : bool
bool
VERSION
VERSION_SERVICE_GITHUB
VERSION_SERVICE_ZEND
latestVersion
| var | |
|---|---|


The first line says this Ox code relies on FiveO. It could also #import niqlow since it includes FiveO.
struct Rosenbrock : BlackBox { … }
The next five lines declare the class of the objective, named Rosenbrock. This is a a BlackBox objective, so we derive Rosenbrock from that predefined class. The objective has two parameters, x and y declared as data members of the Rosenbrock class.
Next, the constructor, Rosenbrock(), is declared, a method with the same name as the class which is called when new Rosenbrock() is executed.
The method that codes ƒ() itself is declared and must have the name vfunc(). The v means that it can return a vector of values to sum up to compute the objective. That is
ƒ() = ∑i vfunc()[i].
This makes it easier to use the BHHH approximation for the Hessian and to relate objectives with non-linear systems. vfunc() takes no arguments. The current values of the parameters are passed through the members of the class.
Rosenbrock ::Rosenbrock () { … }
This method initializes the problem. First, it is necessary for the objective to call the constructor for the parent class, in this case BlackBox(), which takes a string to label output.
Next the parameters of the objective are created. In this problem both x and y can take on any value: -∞ < x < +∞ and the same for y. FiveO designates this as a Free parameter.
Every parameter can be given a label and an initial value can be passed when the parameter is created. The values passed, in this case 0.5 and -0.8, are default starting values that can be used to completely reset the problem. Under some conditions this value will be the actual starting value for the parameter during optimization (x0). But this value can be replaced with a different starting value before optimization begins. This means it is not necessary to change this code to change the starting values, but as a fail safe reasonable starting values are hard-coded.
FiveO must know about the parameters, so they are added to the objective with Parameters(). These three commands to define the parameters and add them can be collapsed to one complicated one:
Parameters(x = new Free("x",0.5),y = new Free("y",-.8));
Encode()
Encode() sets the real starting values of the parameters at their current values, in this case the hard-coded values 0.5 and -0.8. A vector of different values could be sent to Encode(), and starting values can be read from a specially formatted file using Load(). This will attempt to load starting values saved during an earlier optimization run stored in the current folder.
Rosenbrock ::vfunc() {…}
This codes the objective itself. The current values of the parameters are not passed through a vector to be decoded by the user's code (as is typcially done
with generic optimizers and user-defined objectives).
Instead, FiveO always places the current values in the members x and y before calling vfunc().
One member of any Parameter object is v, which is where FiveO puts the values.
So x.v. is the value of the parameter object x and y.v is the value of y. The code uses the niqlow defined function CV(), which will retrieve the value of v for objects passed to it.
Since the Rosenbrock function refers to value of x twice, the code stores the value of x in a local variable (xv).
The advantage of CV(y) over y.v is that it will retrieve the value regardless of whether its argument is a Parameter, an Ox double, an Ox integer, or even a function that returns the value. This means that y can be changed from a constant to a parameter to maximize over to a function of other parameters without changing vfunc().
FiveO imposes constraints and scaling on the parameters. To do this it operates on a free vector, stored in cur.F which typically begins as a vector of ones. Before the user-supplied vfunc() is called F is decoded and re-scaled to create the structural parameter vector, cur.X. Because the values in X are copied into each parameters v member, the user is never required to work with F and X directly.
Decode and Encode are the routines that work between the free and structural parameter vectors.
The code above is then used in a program, perhaps by using #include:
First the code for the problem is included in the program. If the declaration and definition of the Rosenbrock class were placed in separate .oxh and .ox files, then it could be imported instead of included, which is sometimes better when using shared code or possibly combining files that might try to include the same file more than once.
main(){…}
Like C programs, all Ox programs must contain a main() procedure which is where execution starts.
fopen("file","l") captures all output of the program as a log file, so that it can be included in this document below.
The objective will be created and stored in the local main variable obj as will and the two algorithms will used to optimize it, which are stored in alg1 and alg2.
Algorithm and Objective Objects
These are objects of classes, so they are assigned the return value of the new statement. Note that the Algorithms in FiveO require the objective to be optimize be sent as the argument of the creator function. Multiple objectives can be defined, and each can have algorithms associated with it. But once created,
each algorithm object is associated with the objective sent to it. A difference with DDPIn DDP only a single DP problem is defined at a time because it relies heavily on static members to save storage. However,
FiveO avoids static variables so multiple objectives and multiple algorithms can all be created without creating memory conflicts
that static allocation creates.
Volume of output generated
Objective, Algorithm, Bellman and Method classes in niqlow all have Volume data members. These can set separately to control how much output is produced. See NoiseLevels
Here, the volume of each object is set to LOUD which means they will produce a large amount of output (but not the maximum which is NOISY)
Iterate
To apply an optimization algorithm to objective, simply call its Iterate() method.
Different algorithms take different arguments in Iterate, but often the defaults apply so Iterate() may work as desired. The parameters of algorithms can be Tuned before iterating.
When NelderMead ends it leaves the best value of the free parameters in cur.F, and the structural parameters in cur.X. When Iterate() is invoked it starts at the same structural parameters but resets the free parameters.
This resets all parameters of the objective to the values before optimizing (at their hard-coded inital values). This is done to compare NelderMead and Newton from the same starting point.
Delete
It's a good idea to use delete to clean up objects that have been created and will not be needed anymore.
This is especially true because this example also shows how to solve a non-linear system and reuses the variables alg1 and alg2. If they were not deleted first, the memory they currently use would be wasted (and in a large application may become a memory leak).
After 133 function evaluations NelderMead reports that the simplex has collapsed (converged). Sometimes in large, less well-behaved problems, it can be better to reset the simplex after a certain number of function evaluations, but in this case it is unnecessary.
The free parameter for x has gone from 1.0 to 2.0, and for y it has gone from 1.0 (since y to about -1.25. What this means for the real parameters is stated in the final report once Simplex converges: the actual or structural parameters have converged to within 1.0E-5 of the true optimal values x* = y* = 1.0.
Next we see that BFGS agrees. It does not iterate because the norm of the gradient ∇ƒ is close enough to 0 to declare convergence immediately. It terminates without changing the parameters.
ReInitialize
Saved values on disk
Each time FiveO finds an improvement on the objective function it reports on the screen (unless running QUIETly) and writes out to a file. This is designed for slow and difficult optimization problems that one often kills the program before convergence and restarts. Here is the file produced at the end of the process.
The top part of the file is printed using Ox's %v format, which ensures accuracy reading the values back in using Load. The best parameter vector starts on line 4 and continues until > is reached, in this case it is a 2×1 vector. The rest of the file is for information. In particular, the structural vector is printed again with labels, but notice with not quite as many digits.
The user could start at these values by adding obj->Load(0) before the first algorithm is invoked. The 0 means Load() will look in the file created by optimization. The user could also copy the file to Joe.optobj, change the starting values and start there with obj->Load("Joe");. This means that the user can conveniently read starting values from files after saving the default hard-coded values once or the current best vector at any point in a first optimization attempt.
Code refers to classes and functions defined in FiveO so import the module.
struct SysExample : System { … }
As with an objective to optimize, the user creates the system of equations
they want to solve as class derived from a built-in class, in this case System, which is derived or special case of Objective so it very similar to the example above.
Parameters to choose are stored in a member of the class (here x).
Your class has to have creator method (same name as the class itself) because
it will have to call the creator for the parent class.
Ox CreatorsIf you a class Child is derived from Parent, then the
expression new Child() will call the routine Child::Child() as part of creating the new object. If Child::Child() was not defined
nothing is called. So if Parent::Parent() exists (and in FiveO it does and must be called), then the child class has to have
a creator defined and one (and perhaps the only) it does is call Parent(). As a derived class it could use Parent::Parent(), but this is not necessary because it inherits all the methods of the parent class and these are considered part of it so the prefix Parent:: is not needed.
The system of equations is computed and returned by a method that must be called vfunc(). As discussed above, vfunc() is always expected to return a vector even if the class is an objective not a system of equations. The difference with System and with most system solution algorithms is that the
vector is not aggregated into a real number.
SysExample::SysExample(N){…}
THe creator takes the length of the vector as an argument (in the example
N=8, but in the source Ox example it is 99).
It calls the parent creator, and in the case of a system it must send the size of
the system.
In this case it also defines the parameter a vector of Coefficients, which means a vector of Free parameters like regression coefficients. Note that the system need not use vectors. Like the Rosenbrock example above it could give each parameter a different name and store each in different members of the class..
Parameters are added to the objective with Parameters().
Encode() can only be called after all parameters have been added. It can take a argument, but with no arguments each parameter is set to its hard coded value. When x was defined it initialized each one to be 0
SysExample::vfunc() {… }
This method computes and returns the system of equations as a function of
the current value of parameters added to the model.
As discussed above and elsewhere, since parameters are objects their current value is held in its v member (along with other information) and can be
retrieved directly or through the more general CV() routine.
Since
the formula for the system involves three references to the x vector, it is a little more reliable and efficient to get and store the current value rather than access 3 times. The formula is copied from the Ox example and uses the built-in lag0() function.
Line-by-line Explanation (starting from where it ended above)
fopen
Having closed the log file, this opens a new one so that the output of the two
examples can be shown separately.
System and Methods
THe system is created as are two algorithms appropriate for solving a System. In particular, they are derived from NonLinearSystem, which is analogous to
GradientBased family of optimizers.
The variables alg1 and alg2 are re-used to
store these methods.
As with optimization, the objective is sent as the only argument to the
algorithm that will work on it. Multiple algorithms and systems (including nested ones)
can be created, but by sending the system to the algorithm at creation a 1-system for each method mapping is ensured. (However, the same system can be sent to multiple algorithms, so 1-or-more methods for each system.)
ToggleParameterConstraint() is explained elsewhere and is optional, but seems to improve performance in this case.
Volume of outptut is exampled above
Iterate()
To apply the algorithm to its objective call Iterate()
The example shows that after iterating the parameter values are left at their
final values and subsequent iterations start there. This can be changed by calling
Encode() and sending a new vector to start out or (in this example)
ReInitialize() to the hard-coded values.


| quotation {rlang} | R Documentation |
Quotation is a mechanism by which an expression supplied as argument is captured by a function. Instead of seeing the value of the argument, the function sees the recipe (the R code) to make that value. This is possible because R expressions are representable as regular objects in R:
Calls represent the action of calling a function to compute a new value. Evaluating a call causes that value to be computed. Calls typically involve symbols to reference R objects.
Symbols represent the name that is given to an object in a particular context (an environment).
We call objects containing calls and symbols expressions.
There are two ways to create R expressions. First you can build
calls and symbols from parts and pieces (see sym()
, syms()
and
call2()
). The other way is by quotation or quasiquotation,
i.e. by intercepting an expression instead of evaluating it.
expr(expr) enexpr(arg) exprs(..., .named = FALSE, .ignore_empty = c("trailing", "none", "all"), .unquote_names = TRUE) enexprs(..., .named = FALSE, .ignore_empty = c("trailing", "none", "all"), .unquote_names = TRUE, .homonyms = c("keep", "first", "last", "error"), .check_assign = FALSE) ensym(arg) ensyms(..., .named = FALSE, .ignore_empty = c("trailing", "none", "all"), .unquote_names = TRUE, .homonyms = c("keep", "first", "last", "error"), .check_assign = FALSE) quo(expr) enquo(arg) quos(..., .named = FALSE, .ignore_empty = c("trailing", "none", "all"), .unquote_names = TRUE) enquos(..., .named = FALSE, .ignore_empty = c("trailing", "none", "all"), .unquote_names = TRUE, .homonyms = c("keep", "first", "last", "error"), .check_assign = FALSE)
expr |
An expression. |
arg |
A symbol representing an argument. The expression supplied to that argument will be captured instead of being evaluated. |
... |
For |
.named |
Whether to ensure all dots are named. Unnamed
elements are processed with |
.ignore_empty |
Whether to ignore empty arguments. Can be one
of |
.unquote_names |
Whether to treat |
.homonyms |
How to treat arguments with the same name. The
default, |
.check_assign |
Whether to check for |
There are two points of view when it comes to capturing an expression:
You can capture the expressions supplied by the user of your
function. This is the purpose of ensym()
, enexpr()
and
enquo()
and their plural variants. These functions take an
argument name and capture the expression that was supplied to
that argument.
You can capture the expressions that you supply. To this end
use expr()
and quo()
and their plural variants exprs()
and
quos()
.
enexpr()
and expr()
capture a single raw expression.
enexprs()
and exprs()
capture a list of raw expressions
including expressions contained in ...
.
ensym()
and ensyms()
are variants of enexpr()
and
enexprs()
that check the captured expression is either a string
(which they convert to symbol) or a symbol. If anything else
is supplied they throw an error.
In terms of base functions, enexpr(arg)
corresponds to
base::substitute(arg)
(though that function also features complex
substitution semantics) and expr()
is like quote()
(and
bquote()
if we consider unquotation syntax). The plural variant
exprs()
is equivalent to base::alist()
. Finally there is no
function in base R that is equivalent to enexprs()
but you can
reproduce its behaviour with eval(substitute(alist(...)))
.
quo()
and enquo()
are similar to their expr
counterparts but
capture both the expression and its environment in an object called
a quosure. This wrapper contains a reference to the original
environment in which that expression was captured. Keeping track of
the environments of expressions is important because this is where
functions and objects mentioned in the expression are defined.
Quosures are objects that can be evaluated with eval_tidy()
just
like symbols or function calls. Since they always evaluate in their
original environment, quosures can be seen as vehicles that allow
expressions to travel from function to function but that beam back
instantly to their original environment upon evaluation.
See the quosure help topic about tools to work with quosures.
All quotation functions in rlang have support for unquoting operators. The combination of quotation and unquotation is called quasiquotation.
Unquotation provides a way to refer to variables during quotation.
Variables are problematic when quoting because a captured
expression is essentially a constant, just like a string is a
constant. For instance in all the following cases apple
is a
constant: ~apple
, "apple"
and expr(apple)
. Unquoting allows
you to introduce a part of variability within a captured
expression.
In the case of enexpr()
and enquo()
, unquoting provides an
escape hatch to the users of your function that allows them to
manipulate the expression that you capture.
In the case of expr()
and quo()
, quasiquotation lets you
build a complex expressions where some parts are constant (the
parts that are captured) and some parts are variable (the parts
that are unquoted).
See the quasiquotation help topic for more about this as well as the chapter in Advanced R.
# expr() and exprs() capture expressions that you supply: expr(symbol) exprs(several, such, symbols) # enexpr() and enexprs() capture expressions that your user supplied: expr_inputs <- function(arg, ...) { user_exprs <- enexprs(arg, ...) user_exprs } expr_inputs(hello) expr_inputs(hello, bonjour, ciao) # ensym() and ensyms() provide additional type checking to ensure # the user calling your function has supplied bare object names: sym_inputs <- function(...) { user_symbols <- ensyms(...) user_symbols } sym_inputs(hello, "bonjour") ## sym_inputs(say(hello)) # Error: Must supply symbols or strings expr_inputs(say(hello)) # All these quoting functions have quasiquotation support. This # means that you can unquote (evaluate and inline) part of the # captured expression: what <- sym("bonjour") expr(say(what)) expr(say(!!what)) # This also applies to expressions supplied by the user. This is # like an escape hatch that allows control over the captured # expression: expr_inputs(say(!!what), !!what) # Finally, you can capture expressions as quosures. A quosure is an # object that contains both the expression and its environment: quo <- quo(letters) quo get_expr(quo) get_env(quo) # Quosures can be evaluated with eval_tidy(): eval_tidy(quo) # They have the nice property that you can pass them around from # context to context (that is, from function to function) and they # still evaluate in their original environment: multiply_expr_by_10 <- function(expr) { # We capture the user expression and its environment: expr <- enquo(expr) # Then create an object that only exists in this function: local_ten <- 10 # Now let's create a multiplication expression that (a) inlines # the user expression as LHS (still wrapped in its quosure) and # (b) refers to the local object in the RHS: quo(!!expr * local_ten) } quo <- multiply_expr_by_10(2 + 3) # The local parts of the quosure are printed in colour if your # terminal is capable of displaying colours: quo # All the quosures in the expression evaluate in their original # context. The local objects are looked up properly and we get the # expected result: eval_tidy(quo)


Limitless - Editors
Overview
Ace is an embeddable code editor written in JavaScript. It matches the features and performance of native editors such as Sublime, Vim and TextMate. It can be easily embedded in any web page and JavaScript application. Ace is maintained as the primary editor for Cloud9 IDE and is the successor of the Mozilla Skywriter (Bespin) project. Main features:
- Syntax highlighting for over 110 languages (TextMate/Sublime Text.tmlanguage files can be imported)
- Over 20 themes (TextMate/Sublime Text .tmtheme files can be imported)
- Automatic indent and outdent
- An optional command line
- Handles huge documents (four million lines seems to be the limit!)
- Fully customizable key bindings including vim and Emacs modes
- Search and replace with regular expressions
- Highlight matching parentheses
- Toggle between soft tabs and real tabs
- Displays hidden characters
- Drag and drop text using the mouse
- Line wrapping
- Code folding
- Multiple cursors and selections
- Live syntax checker (currently JavaScript/CoffeeScript/CSS/XQuery)
- Cut, copy, and paste functionality
Usage
Ace can be easily embedded into any existing web page. You can either use one of pre-packaged versions of ace (just copy one of src*
subdirectories somewhere into your project), or use requireJS to load contents of lib/ace as ace. By default the editor only supports plain text mode; many other languages are available as separate modules.
Basic markup is:

Panel title
Default
Full featured toolbar

Panel body

Initialize via JavaScript:
// HTML editor
var html_editor = ace.edit("html_editor");
html_editor.setTheme("ace/theme/monokai");
html_editor.getSession().setMode("ace/mode/html");
html_editor.setShowPrintMargin(false);
Plugin info
| Property | Description |
|---|---|
| File name | ace.js, [modes, extensions, themes] |
| Location | assets/js/plugins/editors/ace/ |
| Updates | 0 |
| Links | Github project page |
Overview
Summernote is a JavaScript library that helps you create WYSIWYG editors online. The editor uses open source libraries - jQuery and Bootstrap. Font Awesome was required as well, but i've replaced it with Icomoon icon set. Summernote editor supports keyboard shortcuts, full list you can find in demos by clicking "Help" toolbar button. Summernote has a few special features:
- Paste images from clipboard
- Saves images directly in the content of the field using base64 encoding, so you don't need to implement image handling at all
- Simple UI
- Interactive WYSIWYG editing
- Handy integration with server
Usage
Usage is pretty simple. First include main JS file and Uniform plugin. Uniform is needed to style checkboxes and file inputs inside modal dialogs:

Then place a div
tag somewhere in the body
tag. This element will be replaced with the summernote editor:

Hello Summernote

Finally, run this script after the DOM is ready:
// Initialize plugin
$(document).ready(function() {
$('#summernote').summernote();
});
Custom toolbar
Summernote allows you to make own custom toolbar. To create one, use toolbar
option:
// Font style only toolbar
$('.summernote').summernote({
toolbar: [
//[groupname, [button list]]
['style', ['bold', 'italic', 'underline', 'clear']],
['font', ['strikethrough', 'superscript', 'subscript']],
['fontsize', ['fontsize']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph']],
['height', ['height']],
]
});
You can compose a toolbar with pre-shipped buttons:
| Category | Button id | Function |
|---|---|---|
| Insert | picture |
Insert a picture |
link |
Insert a hyperlink | |
video |
Insert a video | |
table |
Insert a table | |
hr |
Insert a horizontal rule | |
| Style | style |
Format selected block |
fontname |
Set font family | |
fontsize |
Set font size | |
color |
Set foreground and background color | |
bold |
Toggle weight | |
italic |
Toggle italic | |
underline |
Toggle underline | |
strikethrough |
Toggle strikethrough | |
clear |
Clearing all styles | |
| Layout | ul |
Make an un-ordered list |
ol |
Make an ordered list | |
paragraph |
Set text alignment | |
height |
Set height of text | |
| Misc | fullscreen |
Toggle fullscreen editing mode |
codeview |
Toggle wysiwyg and html editing mode | |
undo |
Undo | |
redo |
Redo | |
help |
Show help dialog |
API reference
Usage is pretty simple. First include main JS file and Uniform plugin. Uniform is needed to style checkboxes and file inputs inside modal dialogs:
code
- get the HTML source code underlying the text in the editor:
// Summernote API
var sHTML = $('#summernote').code();
Destroy
Summernote:
// Destroy editor
$('#summernote').destroy();
Note: Full Summernote API can be found on official API documentation pages.
Plugin info
| Property | Description |
|---|---|
| File name | summernote.min.js |
| Location | assets/js/plugins/editors/summernote/ |
| Updates | 0 |
| Links | Github project page |
Overview
WYSIHTML5 is an open source rich text editor based on HTML5 technology and the progressive-enhancement approach. It uses a sophisticated security concept and aims to generate fully valid HTML5 markup by preventing unmaintainable tag soups and inline styles. The code is completely library agnostic: No jQuery, Prototype or similar is required. Main editor features:
- Auto linking of urls as-you-type
- Generates valid and semantic HTML5 markup (no

) - Uses class-names instead of inline styles
- Unifies line-break handling across browsers (hitting enter will create

instead of

or

) - Auto-parses content inserted via copy & paste (from Word, Powerpoint, PDF, other web pages, …)
- Converts invalid or unknown html tags into valid/similar tags
- Source code view for users with HTML skills
- Uses sandboxed iframes in order to prevent identity theft through XSS
- Editor inherits styles and attributes (placeholder, autofocus, …) from original textarea (you only have to style one element)
- Speech-input for Chrome
Usage
Just like in Bootstrap you can activate it without any JavaScript, just by adding a data-attribute, you can make it automatically work. Add data-hover="dropdown" in addition (or in place of) Bootstrap's data-toggle="dropdown". You can set options via data-attributes, too, via data-delay and data-close-others.
1. The first editor script contains the html5 parser rules that are needed for wysihtml5 in order to create valid and desired markup. The second script is the minified wysihtml5 library. Toolbar is placed inside separate file. Also Uniform plugin is added for nice looking checkboxes and file inputs in modal dialogs. Ordering matters:

2. WYSIHTML5 takes a textarea and transforms it into a rich text editor. The textarea acts as a fallback for unsupported browsers (eg. IE < 8). Make sure the textarea element has an id, so we can later access it easily from javascript. The resulting rich text editor will much behave and look like the textarea since behavior (placeholder, autofocus, ...) and css styles will be copied over. Please note: The textarea will always hold the editor's generated markup. Therefore wysihtml5 integrates smoothly with forms.

<form action="#">

<textarea id="wysihtml5-textarea" placeholder="Enter your text ..."></textarea>

</form>
3. And initialize plugin. Make sure you place the


---
layout: null
section-type: about
title: About
---
## About
I’m a Software Engineer with more than 8 years of experience currently specializing in Android development. My Journey in Software Engineering began in 2013 where I was supporting a trading system as a Java developer. Since then, I've got some experience working with Kotlin and Python backends, created Telegram bots, handled servers and CI/CD for a million MAU prooject on GCP platform, developed about 10 Android Apps for product companies. Obtained my MSc in Software Engineering through the Carnegie-Mellon University program in 2016.
Apart from my job I organize meetups and lectures about development. Often speak about various topics. I am currently participating in Android Academy Global where we give free lessons on Android Development that can be found in Youtube.


- HTML
- CSS
creating empowered and engaged teams
Leading, scaling and optimizing teams that drive impactful top level objectives in both the web application and cloud infrastructure spaces.
Hiring, mentoring, and developing individual contributors and the next generation of software development managers.
Leading the developmewnt efforts for systems and applications for handling customer
post sales activities such as returns, cancellations, exchanges and delivery updates.
In addition,
I led the efforts for rebuilding and launching a new chat system for Wayfair support channels.
Transitioned Glympse application stack from a .NET monolith over to a distributed,
cloud native, microservices based set of applications.
Refocused engineering on delivering higher
quality software on a more predictable basis. Established a framework for engaging with the
product team in a more structured way.
Implemented the Desired Outcomes Framework as well as Dual Track
Agile to bring increased focus and velocity to the engineering organization. Worked to simplify
the AWS infrastructure to improve performance as well as reduce the monthly spend.
Supported the engineering efforts for the AWS Mobile Hub product and the AWS Device
Farm product. Streamlined the build and deployment process to be able to deliver updated mobile
SDKs in sync with product releases from across the AWS portfolio of services.
Supported the engineering efforts to build out enterprise capabilities for ZenDesk,
Microsoft Dynamics, Workday and SAP in the AWS Mobile Hub and Mobile SDKs.
Launched full support
for voice-to-text and text-to-voice APIs and SDKs to coincide with the AWS re:INVENT launches of
voice and Alexa support in 2016
Oversaw all of the User Interface engineering across all of the HP Helion Cloud products, as well as the Developer Experience efforts: SDKs, CLIs, IDE integrations, Developer Portal and Cloud Services Marketplace. Areas of focus included leading development teams working with customers and the community on the OpenStack Horizon Dashboard Project. and the HPE NFV Cloud. Provided technical leadership for the rewrite of the the Horizon codebase in AngularJS. Project Technical lead for the OpenStack Searchlight project. Led the development efforts for HP’s CloudSuite management application stack.
Led multiple cross functional teams responsible for building out scalable, highly distributed web applications to enable Rackspace staff to deliver “Fanatical Support” to customers. Built out a fully staffed and capable Product Management team, six engineering teams, a user experience group, and a devops team. Utilizing cutting edge technologies like MongoDB, Elasticsearch and AngularJS, these teams rebuilt our support tools from scratch. Was asked by senior leadership to step in and assist the then nascent Rackspace Developer Relations Group. Immediately saw to the creation of actionable metrics to ensure everyone understood what success looked like before starting to scale the team. By focusing on key hires in the industry, I assembled a top-notch team of SDK authors, Evangelists, and API Documentation specialists and grew the DRG from 3 to 28 in nine months. Oversaw the design and initial build of developer.rackspace.com. Led the release of SDKs and starter kits for the Rackspace Open Cloud in Python, Ruby, .NET, Node, Java and PHP. Oversaw the budget and travel of the evangelists speaking at conferences around the world
Oversaw the technical architecture for all of Yahoo’s Open Social initiatives. Ensured stakeholders were updated, managed global release cycles and maintained zero downtime updates with no breaking API changes downstream. Led the creation of code, documentation, UI assets and style guides to support the relaunch of Yahoo Finance. Upon completion, Yahoo had one code base, supporting 24 languages, globally deployed across 8 datacenters and generating 4+ billion pageviews per day on average. Oversaw the front end engineering efforts in the creation of brand new, services based media properties such as Yahoo Shine and Yahoo Tech. Worked as part of a special Yahoo Media Engineering skunk works development team assigned to build out features and packages across the media properties that fell outside of the capabilities of the existing teams. Examples included a global blogging platform for Yahoo users, free, real-time stock quotes on Yahoo Finance and the first version of what would become Yahoo Fantasy Sports
a dreamer who sees visions of what could be. conjuring up visions of the future. people look to you to describe your visions of the future. They want a picture that can raise their sights. You can paint it for them. People will want to latch on to the hope you bring.
naturally inquisitive. a collector. love to learn new words, memorize facts, collect quotes. excited by the complexity and infinite nature of the world. always seekinbg new facts that can be acquired.
derive strength from close friends. comfortable forming deep relationships with a few confidants. opening up with people you deem worthy. understand the feelings, fears, goals, and dreams of others on a deeper level. will risk vulnerability in exchange for a authenticity.
always ready to start a new project. not deterred by the unknown. feel action is the best way to learn and grow. stay fresh and informed by putting yourself out there and taking the next step. it's not by what we say, but by what we do.
managing the variables to find “the best way”. keep a lot of factors in your mind at all times. open to a brand new opportunities. buy “last-minute” fares & mull over decisions simultaneously. always seeking “the perfect configuration.” love new options, paths of least resistance, and new partnerships.
“stretch the circle wider”. try make people feel like part of a group. avoid groups that exclude. accepting of all faiths, sexes, races and nationalities. cast very few judgments.
For Opportunities, Speaking Engagements, Consulting, or other inquiries.
For Opportunities, Speaking Engagements, Consulting, or other inquiries.


PD: Jack gives way, traps and kills man in Phoenix
by abc15.com staffPHOENIX — Police say a 55-year-old man has died after being trapped underneath a vehicle when the jack he was using gave way.
Emergency crews were called to the scene near 75th avenue and Indian School Road around 1 p.m.
Authorities say the man was transported to the hospital in critical condition but didn't survive his injuries. He is not being identified at this time.
Stay with ABC15 News and abc15.com for updates.


Your go to place for tech
Best Buy is one of Canada’s largest and most successful retailers, operating the Best Buy, Best Buy Mobile, and Geek Squad brands.
Best Selling Products
SAVE with the weekly Best Buy eNewsletter!
Stay updated on our latest prodcut releases, be first to find out about upcoming sales, and get free style tipes from our blog. Unsubscribe at any time.


Brooke Hurford
Front End Development
Ping pong will count up to your number from 1 with the following exceptions:


some9816.net
Profile
Name:some9816
Birthday: 1998/11/16
Location: Hokkaido, Japan
Job: Stundent
Contact:
@some9816
Blog:"some9816's diary"
http://blog.some9816.net
Twitter(@some9816)
https://twitter.com/some9816
Tumblr
http://some9816.tumblr.com/
Instagram
http://instagram.com/some9816
Github
https://github.com/some9816
App.net(@some9816)
https://alpha.app.net/some9816


k2
Businessmodel of K2
Customer Segments
K2 has a mass market business model, with no significant differentiation between customer segments. The company targets its offerings at organizations of all industries and sizes.
Value Proposition
K2 offers two primary value propositions: performance and brand/status.
The company demonstrates strong performance through tangible results. It commissioned Forrester Consulting to identify the benefits of its K2 blackpearl solution. Forrester conducted interviews with several K2 clients and conducted a financial analysis, then used the information to simulate a composite organization using the product. The hypothetical firm saw the following outcomes:
- $6.1 million in Net Present Value (NPV)
- Productivity gains of $3.44 million
- Process application management efficiency gains of $752,541
- Reduction in labor costs by $787,051
- Reduction in application development time by 78%
- Reduction in business process app development costs by $1.1 million
- Payback within 9.2 months
-
466% return on investment after deploying the blackpearl platform Specific positive outcomes for actual clients include the following:
- Credit union First West used K2’s solutions to transform its business banking application process, resulting in a shortening of the process from days/weeks to 40 minutes.
- AXA Wealth used K2’s solutions to automate back-office functions, resulting in the ability to process more than 1,000 tasks per day and more productivity
- Logistics firm GEFCO used K2’s solutions to to improve its invoice management, resulting in the ability to process 700,000 invoice pages per year, up from 40,000
- Kinross Gold used K2’s solutions to automate a dozen processes, resulting in a rise in efficiency and the transformation of $1 billion of manual capital requests into an automated process
-
The Commercial Bank of Qatar used K2’s solutions to improve its loan origination process, resulting in a 50% reduction in FTEs and a 35% reduction in turnaround times The company has established a strong brand due to its success. It has over 1,500 clients in over 84 countries, representing over 1.5 million end-users. Its clients include 30% of the Fortune 100. Its employees operate out of offices in the United States, United Kingdom and Europe, Asia-Pacific, Middle East, and Africa. Lastly, it has won a number of honors, including the following:
- Software & Technology Award for Best Business Process Management Suite from Corporate America magazine
- Network Asia Information Management Award for Most Promising Business App Platform ### Channels
K2’s main channel is its direct sales team. It also sells its products and services through resellers. The company promotes its offerings through its website, social media pages, webinars, and participation in forums, summits, and conferences.
Customer Relationships
K2’s customer relationship is primarily of a personal assistance nature. The company assists customers in the following ways:
Training Services – The company offers training on use of its products in several formats: instructor-led public classroom, instructor-led private on-site, instructor-led virtual, and on-demand virtual. It also enables clients to receive certification so they can demonstrate their expertise.
Professional Services – The company offers two types of services:
- Core Services - Standard consulting services targeted at newer clients. Specific services include platform establishment, onsite mentoring, remote mentoring, and training.
- Full Lifecycle Services – Services that help clients through the entire lifecycle of their implementations. Specific services include Discovery and Definition; Application Design, Architecture, and Planning; Solution Development, Implementation and Knowledge Transfer; and Remote Mentoring. Despite this orientation, there is a self-service component. The company maintains the K2 Learning Library, through which clients can download learning materials. Its website features a “Resources” section that includes white papers, eBooks, case studies, webinars, infographics, and videos. The site also features the “Knowledge Center”, which provides articles and product documentation. There is also a community element in the form of K2 Community , a forum where clients can interact.
Key Activities
K2’s business model entails designing and developing its products for customers.
Key Partners
K2 maintains the following types of partnerships:
- Value-Added Resellers (VAR) – Firms that offer integrated products and services that build K2 solutions into end-user accounts. Specific partners include Acando, Betimes Solutions, CDS Solution Corporation, DataPoint Solutions, Entermarkets Consulting Services, First Digital, and InDocs.
- Global Systems Integrators (GSI) –Firms that support large enterprise customers and help manage integrations of K2 products with their business systems. Specific partners include Avanade, Cognizant Technology Solutions, HCL Technologies Limited, Infosys, and Tata Consultancy Services.
- Delivery Partners – Firms that provide best-practices installations/implementations and expert systems for customers utilizing K2 software. Specific partners include 5th Method, BPIO Consulting, bridgingIT GmbH, Caprivi Solutions, Dynamyx, Dynappix, ES2, jEyLaBs, LogiqueIQ, and slicedbread.
- Technology Alliance Partners – Firms that add complementary capabilities to K2’s platform so its clients can get the most out of their software investments. Specific partners include Adlib, Archon Digital, Box, DocuSign, HotDocs, InRule Technology, Microsoft, Muhimbi, and Qorus Software. Benefits for partners include sales incentives, revenue rebates, product discounts, sales leads, opportunity registration, technical and sales training, marketing funding, and marketing tools.
Key Resources
K2’s main resources are its human resources, who include the engineers that design and develop its products, the sales employees that promote them, the training/consulting employees that provide instruction/advisory services, and the customer service personnel that provide support.
It has relied on funding from outside parties, raising $153.5 million as of April 2015.
Cost Structure
K2 has a value-driven structure, aiming to provide a premium proposition through significant personal service and frequent service enhancements. Its biggest cost driver is likely cost of services, a variable expense.
Other major drivers are in the areas of sales/marketing and customer support/operations, both fixed costs.
Revenue Streams
K2 has two revenue streams: revenues it generates from the sale of its products and revenues it generates from the sale of its services.


Lecture 12 - Publishing & Validation
More about publishing and validation, a more of d3.js in Idyll
We talk a little bit about publishing and carry on with Idyll.
Further example of Idyll pages: website from Spring 2020 which focuses on using d3.js to do many plots since vega-lite was not working well at that time. The index.idyll file, along with example d3 components and a styles.css file for the final map are in this subdirectory from that course page here.
Full corgi dataset available here.
Lecture 12 - Publishing & Validation
More about publishing and validation, a more of d3.js in Idyll
Prep index.idyll file, Week 12
We'll be building toward a webpage like this today using Idyll's built-in components.
Starting histogram component
Histogram component + button
Histogram component + button + slider
This dataset is from the Cardigan Archives and scraped using Beautiful Soup in Python and further processed in Python into this form.
This dataset is from the Cardigan Archives and scraped using Beautiful Soup in Python and further processed in Python into this form.