| Server | Docksal | |
| Backend | Contenta |
|
| Frontend | Nuxt |
|
Docksal is a tool for defining and managing development environments. It brings together common tools, minimizes configuration, and ensures environment consistency throughout your continuous integration workflow.
TL;DR: Docker based development environment.
.docksal/docksal.yml
www:
hostname: www
# Build the www service from a custom Dockerfile.
build:
context: ${PROJECT_ROOT}
dockerfile: ${PROJECT_ROOT}/.docksal/services/www/Dockerfile
volumes:
# Project root volume
- project_root:/var/www:rw,nocopy
labels:
- io.docksal.virtual-host=${VIRTUAL_HOST},*.${VIRTUAL_HOST}
- io.docksal.project-root=${PROJECT_ROOT}
depends_on:
- api
dns:
- ${DOCKSAL_DNS1}
- ${DOCKSAL_DNS2}
ports:
- 80:3000
.docksal/services/www/Dockerfile
# Use Node 6 as our base service.
FROM node:6
# Configure the services environemnt variables.
ENV HOST <IP_ADDRESS>
# Set the working directory to our copied source WWW.
VOLUME ["/var/www"]
WORKDIR /var/www
# Set the NPM start script as our entry command.
CMD '/var/www/.docksal/services/www/entrypoint.sh'
Contenta is a Drupal distribution that gives you modern API capabilities out-of-the box with JSON API.
TL;DR: Decoupled Drupal w/ JSON API.
JSON API is a specification for how a client should request that resources be fetched or modified, and how a server should respond to those requests.
TL;DR: Specification and method of communication.
Nuxt.js is a framework for creating Universal Vue.js Applications.
TL;DR: Frontend webserver.
Vue (pronounced /vjuː/, like view) is a progressive framework for building user interfaces.
The core library is focused on the view layer only, and is easy to pick up and integrate with other libraries or existing projects.
TL;DR: Javascript framework.
A generic JavaScript helper library to query and manipulate Drupal 8 via core REST.
TL;DR: Drupal 8 to JS authentication and communication.
A web framework for building virtual reality experiences.
TL;DR: Virtual Realityloop framework.


We use a large block of connected links for our pagination, making links hard to miss
and easily scalable—all while providing large hit areas. Pagination is built with list
HTML elements so screen readers can announce the number of available links. Use a
wrapping <nav>
element to identify it as a navigation section to
screen readers and other assistive technologies.
In addition, as pages likely have more than one such navigation section, it's
advisable to provide a descriptive aria-label
for the
<nav>
to reflect its purpose. For example, if the pagination
component is used to navigate between a set of search results, an appropriate label
could be aria-label="Search results pages"
.
Looking to use an icon or symbol in place of text for some pagination links? Be sure
to provide proper screen reader support with aria
attributes.
Pagination links are customizable for different circumstances. Use
disabled
for links that appear un-clickable and .active
to
indicate the current page.
While the disabled
prop uses pointer-events: none
to
try to disable the link functionality of <a>
s, that CSS
property is not yet standardized and doesn'taccount for keyboard navigation. As
such, we always add tabindex="-1"
on disabled links and use
custom JavaScript to fully disable their functionality.
Fancy larger or smaller pagination? Add sizing="lg"
or
sizing="sm"
for additional sizes.
Change the alignment of pagination components with flexbox utilities.


Delete or unregister functions, remove indexes, disk stores and regions.
-
Destroy an asynchronous event queue.
-
Delete a disk store and all files on disk used by the disk store.
-
Destroy or unregister a function.
-
Destroy a gateway sender.
-
Destroy or remove the specified index.
-
Destroy the specified JNDI binding.
-
Destroy or remove the specified Lucene index.
-
Destroy or remove a region.
destroy async-event-queue
Destroy an asynchronous event queue.
Availability: Online. You must be connected in gfsh
to a JMX Manager member to use this command.
Syntax:
destroy async-event-queue --id=value [--groups=value(,value)*] [--if-exists=value]
Parameters, destroy async-event-queue:
| Name | Description |
|---|---|
| --id | Required. ID of the async event queue to be deleted. |
| ‑‑groups | Group(s) of members on which the async event queue will be destroyed. If no group is specified, the queue is destroyed on all members. |
| ‑‑if‑exists | If the specified async event queue does not exist, gfsh responds with a message to that effect. If this parameter is true, the response is prefixed with the label “Skipping: ”. Useful for scripted tests. Default (if the parameter is not specified): false. Default (if the parameter is specified without value): true. |
Example Commands:
destroy async-event-queue --id=myAsyncEventQueue
destroy disk-store
Delete a disk store and all files on disk used by the disk store. Data for closed regions that previously used this disk store are lost.
Availability: Online. You must be connected in gfsh
to a JMX Manager member to use this command.
Syntax:
destroy disk-store --name=value [--groups=value(,value)*] [--if-exists=value]
Parameters, destroy disk-store:
| Name | Description |
|---|---|
| --name | Required. Name of the disk store to be deleted. |
| ‑‑groups | Group(s) of members on which the disk store will be destroyed. If no group is specified, the disk store is destroyed on all members. |
| ‑‑if‑exists | If the specified disk store does not exist, gfsh responds with a message to that effect. If this parameter is true, the response is prefixed with the label “Skipping: ”. Useful for scripted tests. Default (if the parameter is not specified): false. Default (if the parameter is specified without value): true. |
Example Commands:
destroy disk-store --name=store1
Sample Output:
gfsh>destroy disk-store --name=store1
Member | Result
------- | -------
server1 | Success
destroy function
Destroy or unregister a function.
The default is for the function to be unregistered from all members.
Availability: Online. You must be connected in gfsh
to a JMX Manager member to use this command.
Syntax:
destroy function --id=value [--groups=value(,value)*] [--member=value]
Parameters, destroy function:
| Name | Description |
|---|---|
| --id | Required. Unique function identifier. Use the list functions command to obtain the ID. |
| --groups | One or more groups of members from which this function will be unregistered. |
| ‑‑member | Name or ID of the member from which this function will be unregistered. |
Example Commands:
(1) destroy function --id=InterestCalculations
(2) destroy function --id=InterestCalculations --member=server1
(3) destroy function --id=InterestCalculations --group=Group1
destroy gateway-sender
Destroy a gateway sender that is no longer used by a region.
The default is for the gateway sender to be destroyed on all members.
No region may be attached to the gateway sender to be destroyed. If a region is still attached, the system issues an error message similar to:
ERROR: The GatewaySender ParallelGatewaySender{id=ln,remoteDsId=2,isRunning =false}
could not be destroyed as it is still used by region(s).
Remove the gateway sender from the region with a command similar to:
gfsh>alter region --name=regionA --gateway-sender-id=""
Availability: Online. You must be connected in gfsh
to a JMX Manager member to use this command.
Syntax:
destroy gateway-sender --id=value [--groups=value(,value)*]
[--members=value(,value)*] [--if-exists=value]
Parameters, destroy gateway-sender:
| Name | Description |
|---|---|
| --id | Required. Unique gateway sender identifier. Use the list gateways command to obtain the ID. |
| --groups | One or more groups of members from which this gateway sender will be destroyed. |
| ‑‑members | Name or ID of the member(s) from which this gateway sender will be destroyed. |
| ‑‑if‑exists | If the specified gateway sender does not exist, gfsh responds with a message to that effect. If this parameter is true, the response is prefixed with the label “Skipping: ”. Useful for scripted tests. Default (if the parameter is not specified): false. Default (if the parameter is specified without value): true. |
Example Commands:
destroy gateway-sender --id=SiteASender
destroy index
Destroy or remove the specified index.
Availability: Online. You must be connected in gfsh
to a JMX Manager member to use this command.
Syntax:
destroy index [--name=value] [--region=value] [--members=value(,value)*]
[--groups=value(,value)*] [--if-exists=value]
Note:
You must specify at least one of the parameter options. If you enter destroy index
without any parameters, the command will ask you to specify at least one option.
Parameters, destroy index:
| Name | Description |
|---|---|
| --name | Name of the index to be removed. |
| ‑‑members | Id of the member(s) on which index is to be removed. |
| --region | Name of the region from which an index or all indexes are to be destroyed. |
| --groups | The index will be removed on all the members in the group(s). |
| ‑‑if‑exists | If the specified index does not exist, gfsh responds with a message to that effect. If this parameter is true, the response is prefixed with the label “Skipping: ”. Useful for scripted tests. Default (if the parameter is not specified): false. Default (if the parameter is specified without value): true. |
Example Commands:
destroy index --members=server2
destroy index --name=MyKeyIndex
destroy jndi-binding
Destroy a specified JNDI binding that holds the configuration for an XA data source.
Availability: Online. You must be connected in gfsh
to a JMX Manager member to use this command.
Syntax:
destroy jndi-binding --name=value [--if-exists=value]
Parameters, destroy jndi-binding:
| Name | Description |
|---|---|
| --name | Required. Name of the JNDI binding to be destroyed. |
| ‑‑if‑exists | Skip the destroy operation when the specified JNDI binding does not exist. Without this option, an error results from the specification of a JNDI binding that does not exist. Default (if the parameter is not specified): false. Default (if the parameter is specified without value): true. |
Example Command:
destroy jndi-binding --name=jndi1
destroy lucene index
Destroy or remove the specified Lucene index.
See also create lucene index, describe lucene index, list lucene indexes and search lucene.
Availability: Online. You must be connected in gfsh
to a JMX Manager member to use this command.
Syntax:
destroy lucene index --region=value [--name=value]
Parameters, destroy lucene index:
| Name | Description |
|---|---|
| ‑‑region | Required. Name of the region from which indexes are to be removed. If no --name option is specified, all indexes associated with the region are destroyed. |
| ‑‑name | Name of the index to be removed. |
Example Commands:
destroy lucene index --region=region1
destroy lucene index --region=region1 --name=MyKeyIndex
destroy region
Destroy or remove a region.
Availability: Online. You must be connected in gfsh
to a JMX Manager member to use this command.
Syntax:
destroy region --name=value [--if-exists=value]
Parameters, destroy region:
| Name | Description |
|---|---|
| --name | Required. Name and path of the region to be removed. |
| ‑‑if‑exists | If the specified region does not exist, gfsh responds with a message to that effect. If this parameter is true, the response is prefixed with the label “Skipping: ”. Useful for scripted tests. Default (if the parameter is not specified): false. Default (if the parameter is specified without value): true. |
Example Commands:
destroy region --name=region4
destroy region --name=/region1/subregion1
Sample Output:
gfsh>destroy region --name=region1
"region1" destroyed successfully.


Hide Soundcloud Tab
Open a
Soudcloud
Tab and
log-in to enable the player
Can't beastify this web page.
Try a different page.


Play now
Live
Leagues
Premier League
+20
LaLiga
+10
Bundesliga
+8
Serie A
First Division B
+4
Countries
England
+68
Spain
+63
Germany
Italy
+117
France
+6
Netherlands
+21


Index
present: [1.] kuñjati
A single occurrence, in the harṣacarita. If not a false reading, is probably an artificial word.


Robbie Williams tells Ryan Tubridy of the terrifying moment he realised he had to get sober
The dad of three admitted it was "stop drinking or die"
by Megan MartinRobbie Williams says Christmas wasn’t always a merry time of year for him, especially when he was forced to quit drinking to save his life almost 20 years ago.
The former Take That singer admitted to “falling out of love with Christmas ” 19 years ago when he “had to give up drinking” as a matter of life or death.
“I haven't had a drink for 19 years. A lot of Christmas for me is wrapped up with euphoric recall of incredible moments in the pub with my friends,” said Williams while promoting his new album ‘The Christmas Present’ on Ryan Tubridy’s radio show Friday morning.
“Then it's a case of 'stop drinking or die' and when you are given that you think 'OK, well I don't want to die, so I better stop drinking',".
Williams said he struggled to get into the sober Christmas spirit for about “four or five years” before meeting his now-wife, Ayda Field, who, he says, goes “overboard” to celebrate the festive period:“But you can’t help getting into the swing of things with her… and now with the kids, it’s even more special”.
Robbie and Ayda have been married since 2010 and share three children together; daughter Teddy, seven, son Charlie, five, and baby girl Coco, 14 months.
"I love being a dad, the universe just beams back at you".


Preparation time
30 mins to 1 hour
Cooking time
10 to 30 mins
Serves
Serves 2
For the pasta, place the flour, eggs and salt into a food processor and blend until the mixture comes together as a dough.
Turn the dough out onto a lightly floured work surface and knead until smooth. Wrap in cling film and leave to rest in the fridge for an hour, if time allows.
Feed the pasta through a pasta machine, beginning on the thickest setting and working down to the thinnest setting. Slice into thin spaghetti using the pasta cutter on the machine.
For the ragù, heat the oil in a frying pan and add the onion and bacon. Fry gently until soft, then add the mushrooms and garlic and stir well.
Add the wine and simmer until reduced by half.
Add the cream and season, to taste, with salt and freshly ground black pepper.
Cook the spaghetti in boiling salted water for 2-3 minutes, then drain and mix with the mushroom ragù.
To serve, divide the spaghetti between two serving bowls.


Food
dddd
234
Beer
Beer
Beer
Beer
Beer
Beer
Beer
Vegetables
Click me
Pumpkin
Aubergine
A link and paragraph is all we need.


YRDSB Teach Assist Support
Is this an official website/app for YRDSB Teach Assist?
No, this is not. This is an unofficial site/app made by students in YRDSB.
Will my data be collected?
Yes, your account will be collected for fetching data from the official teach assist periodically and sending you notifications. Don't worry, your account data will not be shared to third parties or viewed by us. You can learn more about how we deal with your account data in our Privacy Policy.
How to remove my data on your server?
To remove your data, you can contact<EMAIL_ADDRESS>After removing your data, your timeline and archived courses will be cleared.
I can't login, it says "Server Internal Error"
This means our server can't parse data on your account correctly. We will solve this problem as soon as possible. No action on your side is required. Please try again in a few days.
I got a screen with red background and yellow errors on it.
This means the app has problem displaying or processing the data. We will solve this problem as soon as possible. No action on your side is required. Please try again in a few days.
It says my device doesn't support Google Play services so I can't receive notifications.
For Android users, check if you have google play installed on your phone and you can access google from the current network.
For iOS users, check if you can access google from the current network.
If the problem is not solved, please try re-login your account.
I can't receive notifications
Please check if you blocked the notification from the app and you can access google from the current network.
Some information is wrong or not displayed.
Please report this problem by in-app feedback or sending a email to<EMAIL_ADDRESS>Once we received the message, we will solve it as soon as possible.
Your problem is not listed above? Please contact admin@pegasis.site.


Preparation time
30 mins to 1 hour
Cooking time
30 mins to 1 hour
Serves
Makes 1 x 25cm/10in ring-shaped cake
Dietary
Lemon drizzle cakes are an absolute favourite in my house – it’s a wonder I ever make anything else! I chose a ring shape because it looks pretty and you can add more drizzle.
For this recipe you will need a 25cm/10in non-stick fluted ring cake tin.
Preheat the oven to 180C/160C Fan/Gas 4. Grease a 25cm/10in non-stick, fluted ring cake tin with cake release spray or vegetable oil.
Sift the flour and baking powder into a large bowl. Add the rest of the ingredients (except the water) and whisk until smooth using an electric hand mixer. Add about 100ml/3½fl oz hot water from the kettle to slacken the mixture to a soft dropping consistency, if necessary. Pour into the prepared tin and bake for about 35 minutes, or until the cake starts to come away from the sides. To check the cake is ready insert a skewer, if it comes out clean the cake is cooked.
Meanwhile, make the drizzle. Put the lemon juice and sugar in a small saucepan and heat gently until the sugar is dissolved. Increase the heat a little and let it boil for about a minute, or until thickened and syrupy. Add the limoncello, boil for another minute and set aside.
For the decoration, add the lemon slices to the drizzle syrup. Reheat the syrup and simmer for 1-2 minutes or until the lemon slices have softened. Turn off the heat and, using tongs, carefully transfer the lemon slices to a plate lined with greaseproof paper. Leave to cool and reserve any leftover syrup.
When cool enough to handle, make a cut from the centre of the lemon slices to the skin and twist the ends in the opposite direction (so they resemble a bow). Repeat with all the slices, sprinkle with caster sugar and place on a baking tray lined with non-stick paper.
When the cake is cooked, reduce the oven temperature to 100C/80C Fan/Gas ¼.
Leave the cake in the tin while you apply the drizzle. Make holes using a skewer and brush or spoon about a third of the drizzle over the cake. Allow to cool for 5 minutes then turn the cake out onto a wire rack. Make some more holes in the top of the cake (these will be covered with icing later) and brush or spoon the rest of the syrup over the whole cake. Allow to cool completely. When the cake is cool, transfer it to a serving plate or cake board.
Meanwhile, put the lemon twists in the oven to dry out for 30 minutes to 1 hour, until they are chewy (rather than crisp).
Toast the flaked almonds in a dry frying pan until golden-brown, then set aside to cool.
For the icing, mix the icing sugar, limoncello and a little lemon juice until you have a thick icing. Drizzle it over the top of the cake, encouraging it to run down the sides a little. Decorate with the lemon twists, flaked almonds and poppy seeds.


Python Numpy Tutorial
This tutorial was contributed by Justin Johnson.
We will use the Python programming language for all assignments in this course. Python is a great general-purpose programming language on its own, but with the help of a few popular libraries (numpy, scipy, matplotlib) it becomes a powerful environment for scientific computing.
We expect that many of you will have some experience with Python and numpy; for the rest of you, this section will serve as a quick crash course both on the Python programming language and on the use of Python for scientific computing.
Some of you may have previous knowledge in Matlab, in which case we also recommend the numpy for Matlab users page.
Table of contents:
Python
Python is a high-level, dynamically typed multiparadigm programming language. Python code is often said to be almost like pseudocode, since it allows you to express very powerful ideas in very few lines of code while being very readable. As an example, here is an implementation of the classic quicksort algorithm in Python:
def quicksort(arr):
if len(arr) <= 1:
return arr
pivot = arr[len(arr) / 2]
left = [x for x in arr if x < pivot]
middle = [x for x in arr if x == pivot]
right = [x for x in arr if x > pivot]
return quicksort(left) + middle + quicksort(right)
print quicksort([3,6,8,10,1,2,1])
# Prints "[1, 1, 2, 3, 6, 8, 10]"
Python versions
There are currently two different supported versions of Python, 2.7 and 3.4. Somewhat confusingly, Python 3.0 introduced many backwards-incompatible changes to the language, so code written for 2.7 may not work under 3.4 and vice versa. For this class all code will use Python 2.7.
You can check your Python version at the command line by running
python --version
.
Basic data types
Like most languages, Python has a number of basic types including integers, floats, booleans, and strings. These data types behave in ways that are familiar from other programming languages.
Numbers: Integers and floats work as you would expect from other languages:
x = 3
print type(x) # Prints "<type 'int'>"
print x # Prints "3"
print x + 1 # Addition; prints "4"
print x - 1 # Subtraction; prints "2"
print x * 2 # Multiplication; prints "6"
print x ** 2 # Exponentiation; prints "9"
x += 1
print x # Prints "4"
x *= 2
print x # Prints "8"
y = 2.5
print type(y) # Prints "<type 'float'>"
print y, y + 1, y * 2, y ** 2 # Prints "2.5 3.5 5.0 6.25"
Note that unlike many languages, Python does not have unary increment (x++
)
or decrement (x--
) operators.
Python also has built-in types for long integers and complex numbers; you can find all of the details in the documentation.
Booleans: Python implements all of the usual operators for Boolean logic,
but uses English words rather than symbols (&&
, ||
, etc.):
t = True
f = False
print type(t) # Prints "<type 'bool'>"
print t and f # Logical AND; prints "False"
print t or f # Logical OR; prints "True"
print not t # Logical NOT; prints "False"
print t != f # Logical XOR; prints "True"
Strings: Python has great support for strings:
hello = 'hello' # String literals can use single quotes
world = "world" # or double quotes; it does not matter.
print hello # Prints "hello"
print len(hello) # String length; prints "5"
hw = hello + ' ' + world # String concatenation
print hw # prints "hello world"
hw12 = '%s %s %d' % (hello, world, 12) # sprintf style string formatting
print hw12 # prints "hello world 12"
String objects have a bunch of useful methods; for example:
s = "hello"
print s.capitalize() # Capitalize a string; prints "Hello"
print s.upper() # Convert a string to uppercase; prints "HELLO"
print s.rjust(7) # Right-justify a string, padding with spaces; prints " hello"
print s.center(7) # Center a string, padding with spaces; prints " hello "
print s.replace('l', '(ell)') # Replace all instances of one substring with another;
# prints "he(ell)(ell)o"
print ' world '.strip() # Strip leading and trailing whitespace; prints "world"
You can find a list of all string methods in the documentation.
Containers
Python includes several built-in container types: lists, dictionaries, sets, and tuples.
Lists
A list is the Python equivalent of an array, but is resizeable and can contain elements of different types:
xs = [3, 1, 2] # Create a list
print xs, xs[2] # Prints "[3, 1, 2] 2"
print xs[-1] # Negative indices count from the end of the list; prints "2"
xs[2] = 'foo' # Lists can contain elements of different types
print xs # Prints "[3, 1, 'foo']"
xs.append('bar') # Add a new element to the end of the list
print xs # Prints
x = xs.pop() # Remove and return the last element of the list
print x, xs # Prints "bar [3, 1, 'foo']"
As usual, you can find all the gory details about lists in the documentation.
Slicing: In addition to accessing list elements one at a time, Python provides concise syntax to access sublists; this is known as slicing:
nums = range(5) # range is a built-in function that creates a list of integers
print nums # Prints "[0, 1, 2, 3, 4]"
print nums[2:4] # Get a slice from index 2 to 4 (exclusive); prints "[2, 3]"
print nums[2:] # Get a slice from index 2 to the end; prints "[2, 3, 4]"
print nums[:2] # Get a slice from the start to index 2 (exclusive); prints "[0, 1]"
print nums[:] # Get a slice of the whole list; prints ["0, 1, 2, 3, 4]"
print nums[:-1] # Slice indices can be negative; prints ["0, 1, 2, 3]"
nums[2:4] = [8, 9] # Assign a new sublist to a slice
print nums # Prints "[0, 1, 8, 8, 4]"
We will see slicing again in the context of numpy arrays.
Loops: You can loop over the elements of a list like this:
animals = ['cat', 'dog', 'monkey']
for animal in animals:
print animal
# Prints "cat", "dog", "monkey", each on its own line.
If you want access to the index of each element within the body of a loop,
use the built-in enumerate
function:
animals = ['cat', 'dog', 'monkey']
for idx, animal in enumerate(animals):
print '#%d: %s' % (idx + 1, animal)
# Prints "#1: cat", "#2: dog", "#3: monkey", each on its own line
List comprehensions: When programming, frequently we want to transform one type of data into another. As a simple example, consider the following code that computes square numbers:
nums = [0, 1, 2, 3, 4]
squares = []
for x in nums:
squares.append(x ** 2)
print squares # Prints [0, 1, 4, 9, 16]
You can make this code simpler using a list comprehension:
nums = [0, 1, 2, 3, 4]
squares = [x ** 2 for x in nums]
print squares # Prints [0, 1, 4, 9, 16]
List comprehensions can also contain conditions:
nums = [0, 1, 2, 3, 4]
even_squares = [x ** 2 for x in nums if x % 2 == 0]
print even_squares # Prints "[0, 4, 16]"
Dictionaries
A dictionary stores (key, value) pairs, similar to a Map
in Java or
an object in Javascript. You can use it like this:
d = {'cat': 'cute', 'dog': 'furry'} # Create a new dictionary with some data
print d['cat'] # Get an entry from a dictionary; prints "cute"
print 'cat' in d # Check if a dictionary has a given key; prints "True"
d['fish'] = 'wet' # Set an entry in a dictionary
print d['fish'] # Prints "wet"
# print d['monkey'] # KeyError: 'monkey' not a key of d
print d.get('monkey', 'N/A') # Get an element with a default; prints "N/A"
print d.get('fish', 'N/A') # Get an element with a default; prints "wet"
del d['fish'] # Remove an element from a dictionary
print d.get('fish', 'N/A') # "fish" is no longer a key; prints "N/A"
You can find all you need to know about dictionaries in the documentation.
Loops: It is easy to iterate over the keys in a dictionary:
d = {'person': 2, 'cat': 4, 'spider': 8}
for animal in d:
legs = d[animal]
print 'A %s has %d legs' % (animal, legs)
# Prints "A person has 2 legs", "A spider has 8 legs", "A cat has 4 legs"
If you want access to keys and their corresponding values, use the iteritems
method:
d = {'person': 2, 'cat': 4, 'spider': 8}
for animal, legs in d.iteritems():
print 'A %s has %d legs' % (animal, legs)
# Prints "A person has 2 legs", "A spider has 8 legs", "A cat has 4 legs"
Dictionary comprehensions: These are similar to list comprehensions, but allow you to easily construct dictionaries. For example:
nums = [0, 1, 2, 3, 4]
even_num_to_square = {x: x ** 2 for x in nums if x % 2 == 0}
print even_num_to_square # Prints "{0: 0, 2: 4, 4: 16}"
Sets
A set is an unordered collection of distinct elements. As a simple example, consider the following:
animals = {'cat', 'dog'}
print 'cat' in animals # Check if an element is in a set; prints "True"
print 'fish' in animals # prints "False"
animals.add('fish') # Add an element to a set
print 'fish' in animals # Prints "True"
print len(animals) # Number of elements in a set; prints "3"
animals.add('cat') # Adding an element that is already in the set does nothing
print len(animals) # Prints "3"
animals.remove('cat') # Remove an element from a set
print len(animals) # Prints "2"
As usual, everything you want to know about sets can be found in the documentation.
Loops: Iterating over a set has the same syntax as iterating over a list; however since sets are unordered, you cannot make assumptions about the order in which you visit the elements of the set:
animals = {'cat', 'dog', 'fish'}
for idx, animal in enumerate(animals):
print '#%d: %s' % (idx + 1, animal)
# Prints "#1: fish", "#2: dog", "#3: cat"
Set comprehensions: Like lists and dictionaries, we can easily construct sets using set comprehensions:
from math import sqrt
nums = {int(sqrt(x)) for x in range(30)}
print nums # Prints "set([0, 1, 2, 3, 4, 5])"
Tuples
A tuple is an (immutable) ordered list of values. A tuple is in many ways similar to a list; one of the most important differences is that tuples can be used as keys in dictionaries and as elements of sets, while lists cannot. Here is a trivial example:
d = {(x, x + 1): x for x in range(10)} # Create a dictionary with tuple keys
t = (5, 6) # Create a tuple
print type(t) # Prints "<type 'tuple'>"
print d[t] # Prints "5"
print d[(1, 2)] # Prints "1"
The documentation has more information about tuples.
Functions
Python functions are defined using the def
keyword. For example:
def sign(x):
if x > 0:
return 'positive'
elif x < 0:
return 'negative'
else:
return 'zero'
for x in [-1, 0, 1]:
print sign(x)
# Prints "negative", "zero", "positive"
We will often define functions to take optional keyword arguments, like this:
def hello(name, loud=False):
if loud:
print 'HELLO, %s' % name.upper()
else:
print 'Hello, %s!' % name
hello('Bob') # Prints "Hello, Bob"
hello('Fred', loud=True) # Prints "HELLO, FRED!"
There is a lot more information about Python classes in the documentation.
Classes
The syntax for defining classes in Python is straightforward:
class Greeter:
# Constructor
def __init__(self, name):
self.name = name # Create an instance variable
# Instance method
def greet(self, loud=False):
if loud:
print 'HELLO, %s!' % self.name.upper()
else:
print 'Hello, %s' % self.name
g = Greeter('Fred') # Construct an instance of the Greeter class
g.greet() # Call an instance method; prints "Hello, Fred"
g.greet(loud=True) # Call an instance method; prints "HELLO, FRED!"
You can read a lot more about Python classes in the documentation.
Numpy
Numpy is the core library for scientific computing in Python. It provides a high-performance multidimensional array object, and tools for working with these arrays. If you are already familiar with MATLAB, you might find this tutorial useful to get started with Numpy.
Arrays
A numpy array is a grid of values, all of the same type, and is indexed by a tuple of nonnegative integers. The number of dimensions is the rank of the array; the shape of an array is a tuple of integers giving the size of the array along each dimension.
We can initialize numpy arrays from nested Python lists, and access elements using square brackets:
import numpy as np
a = np.array([1, 2, 3]) # Create a rank 1 array
print type(a) # Prints "<type 'numpy.ndarray'>"
print a.shape # Prints "(3,)"
print a[0], a[1], a[2] # Prints "1 2 3"
a[0] = 5 # Change an element of the array
print a # Prints "[5, 2, 3]"
b = np.array([[1,2,3],[4,5,6]]) # Create a rank 2 array
print b.shape # Prints "(2, 3)"
print b[0, 0], b[0, 1], b[1, 0] # Prints "1 2 4"
Numpy also provides many functions to create arrays:
import numpy as np
a = np.zeros((2,2)) # Create an array of all zeros
print a # Prints "[[ 0. 0.]
# [ 0. 0.]]"
b = np.ones((1,2)) # Create an array of all ones
print b # Prints "[[ 1. 1.]]"
c = np.full((2,2), 7) # Create a constant array
print c # Prints "[[ 7. 7.]
# [ 7. 7.]]"
d = np.eye(2) # Create a 2x2 identity matrix
print d # Prints "[[ 1. 0.]
# [ 0. 1.]]"
e = np.random.random((2,2)) # Create an array filled with random values
print e # Might print "[[ 0.91940167 0.08143941]
# [ 0.68744134 0.87236687]]"
You can read about other methods of array creation in the documentation.
Array indexing
Numpy offers several ways to index into arrays.
Slicing: Similar to Python lists, numpy arrays can be sliced. Since arrays may be multidimensional, you must specify a slice for each dimension of the array:
import numpy as np
# Create the following rank 2 array with shape (3, 4)
# [[ 1 2 3 4]
# [ 5 6 7 8]
# [ 9 10 11 12]]
a = np.array([[1,2,3,4], [5,6,7,8], [9,10,11,12]])
# Use slicing to pull out the subarray consisting of the first 2 rows
# and columns 1 and 2; b is the following array of shape (2, 2):
# [[2 3]
# [6 7]]
b = a[:2, 1:3]
# A slice of an array is a view into the same data, so modifying it
# will modify the original array.
print a[0, 1] # Prints "2"
b[0, 0] = 77 # b[0, 0] is the same piece of data as a[0, 1]
print a[0, 1] # Prints "77"
You can also mix integer indexing with slice indexing. However, doing so will yield an array of lower rank than the original array. Note that this is quite different from the way that MATLAB handles array slicing:
import numpy as np
# Create the following rank 2 array with shape (3, 4)
# [[ 1 2 3 4]
# [ 5 6 7 8]
# [ 9 10 11 12]]
a = np.array([[1,2,3,4], [5,6,7,8], [9,10,11,12]])
# Two ways of accessing the data in the middle row of the array.
# Mixing integer indexing with slices yields an array of lower rank,
# while using only slices yields an array of the same rank as the
# original array:
row_r1 = a[1, :] # Rank 1 view of the second row of a
row_r2 = a[1:2, :] # Rank 2 view of the second row of a
print row_r1, row_r1.shape # Prints "[5 6 7 8] (4,)"
print row_r2, row_r2.shape # Prints "[[5 6 7 8]] (1, 4)"
# We can make the same distinction when accessing columns of an array:
col_r1 = a[:, 1]
col_r2 = a[:, 1:2]
print col_r1, col_r1.shape # Prints "[ 2 6 10] (3,)"
print col_r2, col_r2.shape # Prints "[[ 2]
# [ 6]
# [10]] (3, 1)"
Integer array indexing: When you index into numpy arrays using slicing, the resulting array view will always be a subarray of the original array. In contrast, integer array indexing allows you to construct arbitrary arrays using the data from another array. Here is an example:
import numpy as np
a = np.array([[1,2], [3, 4], [5, 6]])
# An example of integer array indexing.
# The returned array will have shape (3,) and
print a[[0, 1, 2], [0, 1, 0]] # Prints "[1 4 5]"
# The above example of integer array indexing is equivalent to this:
print np.array([a[0, 0], a[1, 1], a[2, 0]]) # Prints "[1 4 5]"
# When using integer array indexing, you can reuse the same
# element from the source array:
print a[[0, 0], [1, 1]] # Prints "[2 2]"
# Equivalent to the previous integer array indexing example
print np.array([a[0, 1], a[0, 1]]) # Prints "[2 2]"
Boolean array indexing: Boolean array indexing lets you pick out arbitrary elements of an array. Frequently this type of indexing is used to select the elements of an array that satisfy some condition. Here is an example:
import numpy as np
a = np.array([[1,2], [3, 4], [5, 6]])
bool_idx = (a > 2) # Find the elements of a that are bigger than 2;
# this returns a numpy array of Booleans of the same
# shape as a, where each slot of bool_idx tells
# whether that element of a is > 2.
print bool_idx # Prints "[[False False]
# [ True True]
# [ True True]]"
# We use boolean array indexing to construct a rank 1 array
# consisting of the elements of a corresponding to the True values
# of bool_idx
print a[bool_idx] # Prints "[3 4 5 6]"
# We can do all of the above in a single concise statement:
print a[a > 2] # Prints "[3 4 5 6]"
For brevity we have left out a lot of details about numpy array indexing; if you want to know more you should read the documentation.
Datatypes
Every numpy array is a grid of elements of the same type. Numpy provides a large set of numeric datatypes that you can use to construct arrays. Numpy tries to guess a datatype when you create an array, but functions that construct arrays usually also include an optional argument to explicitly specify the datatype. Here is an example:
import numpy as np
x = np.array([1, 2]) # Let numpy choose the datatype
print x.dtype # Prints "int64"
x = np.array([1.0, 2.0]) # Let numpy choose the datatype
print x.dtype # Prints "float64"
x = np.array([1, 2], dtype=np.int64) # Force a particular datatype
print x.dtype # Prints "int64"
You can read all about numpy datatypes in the documentation.
Array math
Basic mathematical functions operate elementwise on arrays, and are available both as operator overloads and as functions in the numpy module:
import numpy as np
x = np.array([[1,2],[3,4]], dtype=np.float64)
y = np.array([[5,6],[7,8]], dtype=np.float64)
# Elementwise sum; both produce the array
# [[ 6.0 8.0]
# [10.0 12.0]]
print x + y
print np.add(x, y)
# Elementwise difference; both produce the array
# [[-4.0 -4.0]
# [-4.0 -4.0]]
print x - y
print np.subtract(x, y)
# Elementwise product; both produce the array
# [[ 5.0 12.0]
# [21.0 32.0]]
print x * y
print np.multiply(x, y)
# Elementwise division; both produce the array
# [[ 0.2 0.33333333]
# [ 0.42857143 0.5 ]]
print x / y
print np.divide(x, y)
# Elementwise square root; produces the array
# [[ 1. 1.41421356]
# [ 1.73205081 2. ]]
print np.sqrt(x)
Note that unlike MATLAB, *
is elementwise multiplication, not matrix
multiplication. We instead use the dot
function to compute inner
products of vectors, to multiply a vector by a matrix, and to
multiply matrices. dot
is available both as a function in the numpy
module and as an instance method of array objects:
import numpy as np
x = np.array([[1,2],[3,4]])
y = np.array([[5,6],[7,8]])
v = np.array([9,10])
w = np.array([11, 12])
# Inner product of vectors; both produce 219
print v.dot(w)
print np.dot(v, w)
# Matrix / vector product; both produce the rank 1 array [29 67]
print x.dot(v)
print np.dot(x, v)
# Matrix / matrix product; both produce the rank 2 array
# [[19 22]
# [43 50]]
print x.dot(y)
print np.dot(x, y)
Numpy provides many useful functions for performing computations on
arrays; one of the most useful is sum
:
import numpy as np
x = np.array([[1,2],[3,4]])
print np.sum(x) # Compute sum of all elements; prints "10"
print np.sum(x, axis=0) # Compute sum of each column; prints "[4 6]"
print np.sum(x, axis=1) # Compute sum of each row; prints "[3 7]"
You can find the full list of mathematical functions provided by numpy in the documentation.
Apart from computing mathematical functions using arrays, we frequently
need to reshape or otherwise manipulate data in arrays. The simplest example
of this type of operation is transposing a matrix; to transpose a matrix,
simply use the T
attribute of an array object:
import numpy as np
x = np.array([[1,2], [3,4]])
print x # Prints "[[1 2]
# [3 4]]"
print x.T # Prints "[[1 3]
# [2 4]]"
# Note that taking the transpose of a rank 1 array does nothing:
v = np.array([1,2,3])
print v # Prints "[1 2 3]"
print v.T # Prints "[1 2 3]"
Numpy provides many more functions for manipulating arrays; you can see the full list in the documentation.
Broadcasting
Broadcasting is a powerful mechanism that allows numpy to work with arrays of different shapes when performing arithmetic operations. Frequently we have a smaller array and a larger array, and we want to use the smaller array multiple times to perform some operation on the larger array.
For example, suppose that we want to add a constant vector to each row of a matrix. We could do it like this:
import numpy as np
# We will add the vector v to each row of the matrix x,
# storing the result in the matrix y
x = np.array([[1,2,3], [4,5,6], [7,8,9], [10, 11, 12]])
v = np.array([1, 0, 1])
y = np.empty_like(x) # Create an empty matrix with the same shape as x
# Add the vector v to each row of the matrix x with an explicit loop
for i in range(4):
y[i, :] = x[i, :] + v
# Now y is the following
# [[ 2 2 4]
# [ 5 5 7]
# [ 8 8 10]
# [11 11 13]]
print y
This works; however when the matrix x
is very large, computing an explicit loop
in Python could be slow. Note that adding the vector v
to each row of the matrix
x
is equivalent to forming a matrix vv
by stacking multiple copies of v
vertically,
then performing elementwise summation of x
and vv
. We could implement this
approach like this:
import numpy as np
# We will add the vector v to each row of the matrix x,
# storing the result in the matrix y
x = np.array([[1,2,3], [4,5,6], [7,8,9], [10, 11, 12]])
v = np.array([1, 0, 1])
vv = np.tile(v, (4, 1)) # Stack 4 copies of v on top of each other
print vv # Prints "[[1 0 1]
# [1 0 1]
# [1 0 1]
# [1 0 1]]"
y = x + vv # Add x and vv elementwise
print y # Prints "[[ 2 2 4
# [ 5 5 7]
# [ 8 8 10]
# [11 11 13]]"
Numpy broadcasting allows us to perform this computation without actually
creating multiple copies of v
. Consider this version, using broadcasting:
import numpy as np
# We will add the vector v to each row of the matrix x,
# storing the result in the matrix y
x = np.array([[1,2,3], [4,5,6], [7,8,9], [10, 11, 12]])
v = np.array([1, 0, 1])
y = x + v # Add v to each row of x using broadcasting
print y # Prints "[[ 2 2 4]
# [ 5 5 7]
# [ 8 8 10]
# [11 11 13]]"
The line y = x + v
works even though x
has shape (4, 3)
and v
has shape
(3,)
due to broadcasting; this line works as if v
actually had shape (4, 3)
,
where each row was a copy of v
, and the sum was performed elementwise.
Broadcasting two arrays together follows these rules:
- If the arrays do not have the same rank, prepend the shape of the lower rank array with 1s until both shapes have the same length.
- The two arrays are said to be compatible in a dimension if they have the same size in the dimension, or if one of the arrays has size 1 in that dimension.
- The arrays can be broadcast together if they are compatible in all dimensions.
- After broadcasting, each array behaves as if it had shape equal to the elementwise maximum of shapes of the two input arrays.
- In any dimension where one array had size 1 and the other array had size greater than 1, the first array behaves as if it were copied along that dimension
If this explanation does not make sense, try reading the explanation from the documentation or this explanation.
Functions that support broadcasting are known as universal functions. You can find the list of all universal functions in the documentation.
Here are some applications of broadcasting:
import numpy as np
# Compute outer product of vectors
v = np.array([1,2,3]) # v has shape (3,)
w = np.array([4,5]) # w has shape (2,)
# To compute an outer product, we first reshape v to be a column
# vector of shape (3, 1); we can then broadcast it against w to yield
# an output of shape (3, 2), which is the outer product of v and w:
# [[ 4 5]
# [ 8 10]
# [12 15]]
print np.reshape(v, (3, 1)) * w
# Add a vector to each row of a matrix
x = np.array([[1,2,3], [4,5,6]])
# x has shape (2, 3) and v has shape (3,) so they broadcast to (2, 3),
# giving the following matrix:
# [[2 4 6]
# [5 7 9]]
print x + v
# Add a vector to each column of a matrix
# x has shape (2, 3) and w has shape (2,).
# If we transpose x then it has shape (3, 2) and can be broadcast
# against w to yield a result of shape (3, 2); transposing this result
# yields the final result of shape (2, 3) which is the matrix x with
# the vector w added to each column. Gives the following matrix:
# [[ 5 6 7]
# [ 9 10 11]]
print (x.T + w).T
# Another solution is to reshape w to be a row vector of shape (2, 1);
# we can then broadcast it directly against x to produce the same
# output.
print x + np.reshape(w, (2, 1))
# Multiply a matrix by a constant:
# x has shape (2, 3). Numpy treats scalars as arrays of shape ();
# these can be broadcast together to shape (2, 3), producing the
# following array:
# [[ 2 4 6]
# [ 8 10 12]]
print x * 2
Broadcasting typically makes your code more concise and faster, so you should strive to use it where possible.
Numpy Documentation
This brief overview has touched on many of the important things that you need to know about numpy, but is far from complete. Check out the numpy reference to find out much more about numpy.
SciPy
Numpy provides a high-performance multidimensional array and basic tools to compute with and manipulate these arrays. SciPy builds on this, and provides a large number of functions that operate on numpy arrays and are useful for different types of scientific and engineering applications.
The best way to get familiar with SciPy is to browse the documentation. We will highlight some parts of SciPy that you might find useful for this class.
Image operations
SciPy provides some basic functions to work with images. For example, it has functions to read images from disk into numpy arrays, to write numpy arrays to disk as images, and to resize images. Here is a simple example that showcases these functions:
from scipy.misc import imread, imsave, imresize
# Read an JPEG image into a numpy array
img = imread('assets/cat.jpg')
print img.dtype, img.shape # Prints "uint8 (400, 248, 3)"
# We can tint the image by scaling each of the color channels
# by a different scalar constant. The image has shape (400, 248, 3);
# we multiply it by the array [1, 0.95, 0.9] of shape (3,);
# numpy broadcasting means that this leaves the red channel unchanged,
# and multiplies the green and blue channels by 0.95 and 0.9
# respectively.
img_tinted = img * [1, 0.95, 0.9]
# Resize the tinted image to be 300 by 300 pixels.
img_tinted = imresize(img_tinted, (300, 300))
# Write the tinted image back to disk
imsave('assets/cat_tinted.jpg', img_tinted)
MATLAB files
The functions scipy.io.loadmat
and scipy.io.savemat
allow you to read and
write MATLAB files. You can read about them
in the documentation.
Distance between points
SciPy defines some useful functions for computing distances between sets of points.
The function scipy.spatial.distance.pdist
computes the distance between all pairs
of points in a given set:
import numpy as np
from scipy.spatial.distance import pdist, squareform
# Create the following array where each row is a point in 2D space:
# [[0 1]
# [1 0]
# [2 0]]
x = np.array([[0, 1], [1, 0], [2, 0]])
print x
# Compute the Euclidean distance between all rows of x.
# d[i, j] is the Euclidean distance between x[i, :] and x[j, :],
# and d is the following array:
# [[ 0. 1.41421356 2.23606798]
# [ 1.41421356 0. 1. ]
# [ 2.23606798 1. 0. ]]
d = squareform(pdist(x, 'euclidean'))
print d
You can read all the details about this function in the documentation.
A similar function (scipy.spatial.distance.cdist
) computes the distance between all pairs
across two sets of points; you can read about it
in the documentation.
Matplotlib
Matplotlib is a plotting library.
In this section give a brief introduction to the matplotlib.pyplot
module,
which provides a plotting system similar to that of MATLAB.
Plotting
The most important function in matplotlib is plot
,
which allows you to plot 2D data. Here is a simple example:
import numpy as np
import matplotlib.pyplot as plt
# Compute the x and y coordinates for points on a sine curve
x = np.arange(0, 3 * np.pi, 0.1)
y = np.sin(x)
# Plot the points using matplotlib
plt.plot(x, y)
plt.show() # You must call plt.show() to make graphics appear.
Running this code produces the following plot:
With just a little bit of extra work we can easily plot multiple lines at once, and add a title, legend, and axis labels:
import numpy as np
import matplotlib.pyplot as plt
# Compute the x and y coordinates for points on sine and cosine curves
x = np.arange(0, 3 * np.pi, 0.1)
y_sin = np.sin(x)
y_cos = np.cos(x)
# Plot the points using matplotlib
plt.plot(x, y_sin)
plt.plot(x, y_cos)
plt.xlabel('x axis label')
plt.ylabel('y axis label')
plt.title('Sine and Cosine')
plt.legend(['Sine', 'Cosine'])
plt.show()
You can read much more about the plot
function
in the documentation.
Subplots
You can plot different things in the same figure using the subplot
function.
Here is an example:
import numpy as np
import matplotlib.pyplot as plt
# Compute the x and y coordinates for points on sine and cosine curves
x = np.arange(0, 3 * np.pi, 0.1)
y_sin = np.sin(x)
y_cos = np.cos(x)
# Set up a subplot grid that has height 2 and width 1,
# and set the first such subplot as active.
plt.subplot(2, 1, 1)
# Make the first plot
plt.plot(x, y_sin)
plt.title('Sine')
# Set the second subplot as active, and make the second plot.
plt.subplot(2, 1, 2)
plt.plot(x, y_cos)
plt.title('Cosine')
# Show the figure.
plt.show()
You can read much more about the subplot
function
in the documentation.
Images
You can use the imshow
function to show images. Here is an example:
import numpy as np
from scipy.misc import imread, imresize
import matplotlib.pyplot as plt
img = imread('assets/cat.jpg')
img_tinted = img * [1, 0.95, 0.9]
# Show the original image
plt.subplot(1, 2, 1)
plt.imshow(img)
# Show the tinted image
plt.subplot(1, 2, 2)
# A slight gotcha with imshow is that it might give strange results
# if presented with data that is not uint8. To work around this, we
# explicitly cast the image to uint8 before displaying it.
plt.imshow(np.uint8(img_tinted))
plt.show()


Plain of Tears [at30], plain, in Mandoria, peasants: 151
Last updated Turn #137
Plain of Tears [at30], plain, in Mandoria, peasants: 151
------------------------------------------------------------------------
14: Horde of rats [ag2r], rats, number: 34, went south.
18: Band of thieves [cq3b], bandits, number: 58, arrived from the north.
20: Band of thieves [cq3b], bandits, number: 58, went north.
24: Stack of savages [jf6u], savages, number: 20, arrived from the north.
30: It has stopped raining.
30: The population grows by one peasant.
Routes leaving Plain of Tears:
North, plain, to Plain of Tears [as30], 7 days
East, plain, to Plain of Tears [at31], 7 days
Garrison [jk7u], garrison, uncontrolled, with seven peasants
South, plain, to Plain of Tears [au30], 7 days
West, plain, to Plain of Tears [at29], 7 days
Inner locations:
Poppy field [ae1l], poppy field, 1 day, owner:
Centaur [af9q], centaurs, number: 15
Seen here:
Stack of savages [jf6u], savages, number: 20


Cancer Warriors Treated to a Day of Relaxation and Pampering
'Chavelyta's Pamper-me Day', was put on by the organization Chavelyta's Pink Hood--run by Isabel Guillen, a cancer survivor. "I felt like these women needed that type of support," Guillen said. "I had received it myself going through that treatment." This year, over 100 people, including patients and their loved ones, were pampered by Chavelyta's volunteer glam squad. Over a hundred volunteers, which included makeup artists, hairdressers, barbers, manicurists, chefs and many more, volunteered their time and resources to make this a success for those who are battling the disease.


| add_stat {gtsummary} | R Documentation |
The function allows a user to add a new column (or columns) of statistics to an
existing tbl_summary
or tbl_svysummary
object.
add_stat( x, fns, location = NULL, fmt_fun = NULL, header = NULL, footnote = NULL, new_col_name = NULL )
x |
|
fns |
list of formulas indicating the functions that create the statistic. See details below. |
location |
list of formulas indicating the location the new statistics
are placed. The RHS of the formula must be one of |
fmt_fun |
DEPRECATED. |
header |
DEPRECATED. |
footnote |
DEPRECATED. |
new_col_name |
DEPRECATED. |
The returns from custom functions passed in fns=
are required to follow a
specified format. Each of these function will execute on a single variable from
tbl_summary()
/tbl_svysummary()
.
Each function must return a tibble or a vector. If a vector is returned, it will be converted to a tibble with one column and number of rows equal to the length of the vector.
When location = "label"
, the returned statistic from the custom function
must be a tibble with one row. When location = "level"
the tibble must have
the same number of rows as there are levels in the variable (excluding the
row for unknown values).
Each function may take the following arguments: foo(data, variable, by, tbl, ...)
data=
is the input data frame passed to tbl_summary()
variable=
is a string indicating the variable to perform the calculation on
by=
is a string indicating the by variable from tbl_summary=
, if present
tbl=
the original tbl_summary()
/tbl_svysummary()
object is also available to utilize
The user-defined does not need to utilize each of these inputs. It's
encouraged the user-defined function accept ...
as each of the arguments
will be passed to the function, even if not all inputs are utilized by
the user's function, e.g. foo(data, variable, by, ...)
Use modify_header()
to update the column headers
Use modify_fmt_fun()
to update the functions that format the statistics
Use modify_footnote()
to add a explanatory footnote
If you return a tibble with column names p.value
or q.value
, default
p-value formatting will be applied, and you may take advantage of subsequent
p-value formatting functions, such as bold_p()
or add_q()
.
Example 1
Example 2
Example 3
library(dplyr, warn.conflicts = FALSE) library(stringr) # Example 1 ---------------------------------- # fn returns t-test pvalue my_ttest <- function(data, variable, by, ...) { t.test(data[[variable]] ~ as.factor(data[[by]]))$p.value } add_stat_ex1 <- trial %>% select(trt, age, marker) %>% tbl_summary(by = trt, missing = "no") %>% add_stat(fns = everything() ~ my_ttest) %>% modify_header( list( add_stat_1 ~ "**p-value**", all_stat_cols() ~ "**{level}**" ) ) # Example 2 ---------------------------------- # fn returns t-test test statistic and pvalue my_ttest2 <- function(data, variable, by, ...) { t.test(data[[variable]] ~ as.factor(data[[by]])) %>% broom::tidy() %>% mutate( stat = str_glue("t={style_sigfig(statistic)}, {style_pvalue(p.value, prepend_p = TRUE)}") ) %>% pull(stat) } add_stat_ex2 <- trial %>% select(trt, age, marker) %>% tbl_summary(by = trt, missing = "no") %>% add_stat(fns = everything() ~ my_ttest2) %>% modify_header(add_stat_1 ~ "**Treatment Comparison**") # Example 3 ---------------------------------- # return test statistic and p-value is separate columns my_ttest3 <- function(data, variable, by, ...) { t.test(data[[variable]] ~ as.factor(data[[by]])) %>% broom::tidy() %>% select(statistic, p.value) } add_stat_ex3 <- trial %>% select(trt, age, marker) %>% tbl_summary(by = trt, missing = "no") %>% add_stat(fns = everything() ~ my_ttest3) %>% modify_header( list( statistic ~ "**t-statistic**", p.value ~ "**p-value**" ) ) %>% modify_fmt_fun( list( statistic ~ style_sigfig, p.value ~ style_pvalue ) )


Frequently Asked Questions
How do I become a member?
Membership is by invitation only. You will be notified via email and mail if you qualify for candidacy.
I am a candidate. Where can I find all the general information and due dates?
You should have received both a letter and an email with various resources. You can also visit our candidate folder under "Links"
What is candidacy based off of?
Candidacy is based off of major GPA. Check our requirements page for specifics.
What if I can't pay the membership fee?
Contact the President and the Treasurer to discuss any other possible options.
What if I cannot attend enough events?
Contact one of the officers to discuss any other possible options.
I'm not getting any emails from TBP. What's going on?
It may be the case that our emails are going to your spam folder. Also, certain emails are only sent to active members. If you are not an active member, you may not receive certain emails.
I had a similar GPA as my friend and they received an invitation, but I didn’t. Why is that?
It is possible that you received an invitation, but the email went to your spam folder. It is also possible that your friend had a slightly higher GPA and the cut off was between you two.
I am a second year, but received an invitation. Was this a mistake?
No, the junior or senior standing is based on how many units you have.
I am a transfer student and meet the requirements, but didn’t receive an invite.
Transfer students need to be at SJSU for at least 1 semester before qualifying.
Where do I submit graduation/alumni/eminent engineer documents?
These documents should be sent to the Dean's Office (ENGR493)
I am a graduate students. Are the requirements the same?
No, graduate students have different requirements. Please refer to the requirements page for details.
Does being a mentor meet the requirements for being an active member?
Yes, mentors automatically meet active member requirements.
I am a TBP Member from another chapter. Am I allowed to attend events?
Yes, any TBP member can attend our events. Just contact an officer and let us know you are coming.
Is it true that our website was taken down by professors?
No, the website was experiencing server issues last year and this had nothing to do with faculty. It has now been rebuilt and will stay up and running.


A platform to organize and connect a user’s job search. We allow user’s to organize and track their job search process, from establishing connections to recruiters and etc. Additionally, user’s can be matched with jobs (indeed API or whatever) based off of similar postings/interests.


Includes documentation on what the QuickpayV10 app contains and how to set it up in uCommerce.
#Supported Features
Quickpay for uCommerce supports the following features:


Post-parsing
AnemometerModel.php
Helpers.php
Loader.php
MySQLTableReport.php
QueryExplain.php
QueryTableParser.php
Anemometer.php
Warnings:
Warning on line 20 - no @package tag was used in a DocBlock for class Anemometer
Warning on line 20 - Unknown tag "@created" used
Warning on line 422 - File "/box/www/anemometer/lib/Anemometer.php" has no page-level DocBlock, use @package in the first DocBlock to create one
AnemometerModel.php
Warnings:
Warning on line 15 - Unknown tag "@created" used
Warning on line 15 - no @package tag was used in a DocBlock for class AnemometerModel
Warning on line 347 - File "/box/www/anemometer/lib/AnemometerModel.php" has no page-level DocBlock, use @package in the first DocBlock to create one
Helpers.php
Warnings:
Warning on line 10 - Unknown tag "@created" used
Warning on line 17 - no @package tag was used in a DocBlock for file /box/www/anemometer/lib/Helpers.php
Loader.php
Warnings:
Warning on line 8 - Unknown tag "@created" used
Warning on line 9 - no @package tag was used in a DocBlock for class Loader
Warning on line 49 - File "/box/www/anemometer/lib/Loader.php" has no page-level DocBlock, use @package in the first DocBlock to create one
MySQLTableReport.php
Warnings:
Warning on line 95 - no @package tag was used in a DocBlock for class MySQLTableReport
Warning on line 95 - Unknown tag "@created" used
Warning on line 975 - File "/box/www/anemometer/lib/MySQLTableReport.php" has no page-level DocBlock, use @package in the first DocBlock to create one
QueryExplain.php
Warnings:
Warning on line 44 - Unknown tag "@created" used
Warning on line 45 - no @package tag was used in a DocBlock for class QueryExplain
Warning on line 286 - File "/box/www/anemometer/lib/QueryExplain.php" has no page-level DocBlock, use @package in the first DocBlock to create one
QueryTableParser.php
Warnings:
Warning on line 21 - no @package tag was used in a DocBlock for class QueryTableParser
Warning on line 21 - Unknown tag "@created" used
Warning on line 100 - File "/box/www/anemometer/lib/QueryTableParser.php" has no page-level DocBlock, use @package in the first DocBlock to create one
Documentation generated on Mon, 12 Mar 2012 11:59:41 -0700 by phpDocumentor 1.4.4


Mortgage Paydown Benefits
A consumer outreach project by
Mortgage Loan Amount
Interest Rate as %
How much extra you pay per month
Total Mortgage Cost Before
Total Mortgage Cost After
How much you
SAVE
191,000
-
160,000
=
29,000
Time to payoff before
Time to Payoff After
Time Saved
30 years
-
22 years
=
8 years


What is the instrument precision in the absence of other (larger) random-error contributions to the precision?


---
layout: post
title: 2/5 schoolwork
date: '2014-02-05T21:46:00.000-07:00'
author: Jacob .
tags:
modified_time: '2014-02-05T21:46:00.826-07:00'
blogger_id: tag:blogger.com,1999:blog-6400085873105072120.post-2668957899028656021
blogger_orig_url: http://www.svlark.com/2014/02/25-schoolwork.html
---
History:
- read about Theseus and the Minotaur in Chapter 18 "Life in Early Crete"
- answered review questions
- dictation and narration
- colored bull-jumpers
- Minotaur Labyrinth maze
Grammar
- Lesson 67
Math
- 8 number bonds


A list of the projects that I've done (in a team or on my own). Please refer to the github ReadMe's for more elaborate descriptions. The videos might be in Dutch.
-
-
-
E-corp
The software + hardware (money dispenser) of a bank. Combining many components like Arduino, a Java application and a server with database
github
E-corp
The software + hardware (money dispenser) of a bank. Combining many components like Arduino, a Java application and a server with database
github


{% extends "datapages/realtime_generated_base.html" %} {% load staticfiles %} {% block sitecss %} {{ block.super }} {% endblock sitecss %} {% block pagetitle %}2013-14 Return on investment overview {% endblock pagetitle %} {% block rtmain_generated %}
This analysis considers independent expenditures made during the 2014 general election, and whether it achieved it's objective. The return on investment we calculated counts money spent backing winners and opposing losers as successful, and money spent backing losers or opposing winners. Money spent on races that have not been decided is not counted. We will update it as results come in.
To be precise, we calculate return on investment as: ( independent expenditures made in the general election supporting identifiable candidates who won + independent expenditures made in the general election opposing identifiable candidates who lost) / ( independent expenditures made in the general election supporting identifiable candidates who won + independent expenditures made in the general election opposing identifiable candidates who lost + independent expenditures made in the general election opposing identifiable candidates who won + independent expenditures made in the general election supporting identifiable candidates who lost )


You can apply wildcard filter(s) when detecting changes and copying files. By default, the system will filter out hidden files, on Unix, that means files/folder starting with ".", on Windows, that means files/folders with "hidden" attribute. You may want to filter out, e.g. files with ".tmp" extension.
Note: filters are applied on both sides, source and destination (i.e. the workspace). E.g. if you filter out ".tmp" files, all ".tmp" files currently in workspace will not be removed.


We will use this on our website, on banners and posters for the event, and elsewhere. Feel free to upload a ZIP with multiple versions and we will use them as appropriate.
If you don't want us to post anything, just leave all this blank. But if you do,
what should we post on Facebook?
Upload any assets like images, videos and GIFs to use with this post.
Once you click publish, you will no longer be able to modify your entry and your post will be uploaded to Facebook by us within a few days.
If you don't want us to tweet anything, just leave all this blank. But if you
do, what should we tweet about you?
Upload any assets like images, videos and GIFs to use with this tweet.
Once you click publish, you will no longer be able to modify your entry and your post will be uploaded to Twitter by us within a few days.
If you don't want us to post anything, just leave all this blank. But if you do, select an
image to upload to Instagram.
What should we caption the picture?
Once you click publish, you will no longer be able to modify your entry and your post will be uploaded to Instagram by us within a few days.


The CS is being worked to run using an Arduino Mega type of microcontroller system.
Could run in other Arduino type of machines, but that is not being tested in the main project.
What this machine do is to produce breathing cycles, that are a medium to send air to a patient and to release that air in a controlled way. So, there are many different events but they can't appear in the middle of any of these cycles (each cycle must finish according with the information the machine had before that cycle began). The only exception is the "Hold" event, that stop the machine "before" the release internal operation is performed.
As an Arduino system, it has been organized in the following elements:
Together with a "shared" data structure known as its "context"
The actions are independent functions stored in a vector that are located by an index ( O(1) speed ). The current defined actions are:
These instructions to perform the actions are received on the Serial Arduino line from the AC (typically a Single Board Computer) connected through a USB cable.
The modes are the methodologies or algorithms the machine follow to achieve its goals. They are corresponding to formal medical ventilator modes:
Take into consideration that not all these modes will be ready now, as this is a "work in progress".
The sensors collect certain runtime data and events. Here we have:
The actuators are the ones performing the physical actions. We have:
Possibly, the BigValveMask be one of these:
And what the actuator do is to press and release the bag in a controlled period of time and pause following different possible methods. This is why Nihtui is not limited to any of them; who uses this control system must add the particular programming that controls how the bag is pressed and released.
An option is to use a step-motor with a strap, as the original Botta document describes. A different one is following the Spanish Oxygen project suggestion, using some paddle that press the bag. In any case, the idea is to use all the data the controller offers to define how to use these physical elements to perform the specified task.


---
sort_order: 82
tei_id: rdx_b5j2m.p.idm59945072
annotation_count: 0
images:
small-thumbnail: http://readux.library.emory.edu/books/emory:b5j2m/pages/emory:p764b/mini-thumbnail/
json: http://readux.library.emory.edu/books/emory:b5j2m/pages/emory:p764b/info/
full: http://readux.library.emory.edu/books/emory:b5j2m/pages/emory:p764b/fs/
page: http://readux.library.emory.edu/books/emory:b5j2m/pages/emory:p764b/single-page/
thumbnail: http://readux.library.emory.edu/books/emory:b5j2m/pages/emory:p764b/thumbnail/
title: Page 82
number: 82
---
{% raw %}CHAPTER XII.{% endraw %}
{% raw %}ESCAPE FEOM EOXDAGE.{% endraw %}
{% raw %}SOLITARY MUSINGS.—PREPARATIONS FOR FLIGHT.—A LONG GOOD{% endraw %}
{% raw %}NIGHT TO MASTER.—A DARK NIGHT ON THE RIVER.—NIGHT{% endraw %}
{% raw %}.JOURNEYS IN INDIANA.—ON THE BRINK OF STARVATION.—A{% endraw %}
{% raw %}KIND WOMAN.—A NEW STYLE OF DRINKING CUP.—REACH{% endraw %}
{% raw %}CINCINNATI.{% endraw %}
{% raw %}During the bright and hopeful days I spent in{% endraw %}
{% raw %}Ohio, while away on my preaching tour, I had{% endraw %}
{% raw %}heard much of the course pursued by fugitives from{% endraw %}
{% raw %}slavery, and became acquainted with a number of{% endraw %}
{% raw %}benevolent men engaged in helping them on their{% endraw %}
{% raw %}way. Canada was often spoken of as the only sure{% endraw %}
{% raw %}refuge from pursuit, and that blessed land was now{% endraw %}
{% raw %}the desire of my longing heart. Infinite toils and{% endraw %}
{% raw %}perils lay between me and that haven of promise,{% endraw %}
{% raw %}enough to daunt the stoutest heart; but the fire{% endraw %}
{% raw %}behind me was too hot and fierce to let me pause to{% endraw %}
{% raw %}consider them. I knew the North Star—blessed be{% endraw %}
{% raw %}God for setting it in the heavens ! Like the Star of{% endraw %}
{% raw %}Bethlehem, it announced where my salvation lay.{% endraw %}
{% raw %}Could I follow it through forest, and stream, and{% endraw %}
{% raw %}field, it would guide my feet in the way of hope. I{% endraw %}
{% raw %}thought of it as my God-given guide to the land of{% endraw %}
{% raw %}promise far away beneath its light. I knew that it{% endraw %}
{% raw %}had led thousands of my poor, hunted brethren to{% endraw %}


This record stores key performance indicator mdx metadata.
Record Data — BIFF8 only
|
Offset |
Name |
Size |
Contents |
|
4 |
Rt |
2 |
Record type; this matches the BIFF rt in the first two bytes of the record; =0889h |
|
6 |
grbitFrt |
2 |
FRT cell reference flag; =0 currently |
|
8 |
(Reserved) |
8 |
Currently not used, and set to 0 |
|
16 |
istrConnName |
4 |
Index of connection name in string store |
|
20 |
tfnSrc |
1 |
Tag of the Cube function producing mdx metadata |
|
21 |
kpiprop |
1 |
Key performance indicator property |
|
22 |
istrKPIName |
4 |
Index of member unique name in string store |
|
26 |
istrMbrKPI |
4 |
Index of key performance indicator name in string store |
The tfnSrc field contains one of the following values:
|
tfnSrc |
Cube function |
|
07h |
CUBEKPIMEMBER |
The kpiprop field contains one of the following values:
|
kpiprop |
Key performance indicator property |
|
01h |
Value |
|
02h |
Goal |
|
03h |
Status |
|
04h |
Trend |
|
05h |
Weight |
|
06h |
Current time member |


son dakika
Toggle navigation
Action
Another action
Something else here
Separated link
One more separated link
Submit
Action
Another action
Something else here
Separated link
Manşet haber !
This is a panel
Videolar
This is a panel
Haberler
This is a panel
Yazarlar
Home
Profile
Messages
Settings
a
.b
c
d...
Galeri
ss
6
7


Preparation time
less than 30 mins
Cooking time
30 mins to 1 hour
Serves
Serves 4
Dietary
A classic fragrant tarka dal with sweet fruity apricot naan breads makes a perfect vegetarian dinner.
For the tarka dahl, place the lentils, ginger and turmeric into a saucepan, cover with water and bring to the boil. Skim any scum from the surface, then reduce the heat until the mixture is simmering and simmer the lentils for 25-30 minutes, or until tender. Drain well.
Meanwhile, heat a frying pan until hot, add two tablespoons of the ghee and all of the finely chopped onion, ground cumin, ground coriander and chilli powder and cook for 2-3 minutes. Add the garlic and fresh red chilli and cook for a further 1-2 minutes, or until softened.
Add the tomatoes and cook for 1-2 minutes, or until the tomatoes have broken down and the mixture has thickened slightly. Add the cooked, drained lentils and stir to combine. Season, to taste, with salt and freshly ground black pepper.
Meanwhile, heat the remaining ghee in a separate frying pan, add the sliced onion and the dried red chilli and fry over a high heat for 4-5 minutes, or until the onion is crisp and golden-brown.
For the apricot and coriander naan breads, place the flour, sugar, yeast, baking powder and salt into a bowl and mix well to combine.
Whisk together the milk, yoghurt, egg and one tablespoon of the ghee together in a separate bowl until well combined.
Make a well in the centre of the dry ingredients in the first bowl and pour in the milk mixture, mixing to form a soft dough.
Knead the dough on a lightly floured work surface for ten minutes, or until smooth and elastic. Place in a greased bowl, cover with a clean tea towel and leave to rise (prove) for one hour.
Meanwhile, preheat the grill to high and the oven to 230C/450F/Gas 8. Place a baking sheet into the preheated oven.
When the dough has risen, remove it from the bowl and knock back to remove most of the air. Knead once more, then divide into four equal portions.
Roll and stretch each dough portion into a teardrop-shaped piece, as large and thin as possible. Mix one teaspoon of the ground coriander with the remaining ghee and the other teaspoon of ground coriander with the chopped apricots.
Sprinkle the apricot and coriander mixture lengthways over one half of each piece of dough. Fold over and press down lightly, then reshape into a tear drop shape, using a rolling pin.
Place the dough onto the preheated baking sheet, transfer to the oven and bake for 4-5 minutes, turning halfway through. Remove from the oven, brush with the coriander and ghee mixture, then grill the breads under the preheated grill for 1-2 minutes, until golden-brown on top.
To serve, spoon the dahl into four serving bowls, scatter over the crisp onions and chilli and sprinkle over the chopped coriander. Serve the naan bread alongside.


Sunday horse betting tip of the day
The Citizen brings daily horse racing tips to its premium online subscribers.
by Phumelela RacingPREMIUM!
Greyville Turf 24-11-19 Best Bet Race 9 No 5 Baby Shooz On betting alone, Baby Shooz – backed to even money favourite – should have absolutely no trouble outclassing rivals when he teams up with multiple champion jockey Anton Marcus, over a 1600m trip that should suit him perfectly. Considering he was returning from a lengthy layoff, drawn appallingly and forced to run on from near last most recently, the fact he was only beaten two lengths by Brass Bell suggests he is a decent sort. Now that he is beautifully drawn at No 3 and will strip a fitter...
Greyville Turf 24-11-19
Best Bet
Race 9 No 5 Baby Shooz
On betting alone, Baby Shooz – backed to even money favourite – should have absolutely no trouble outclassing rivals when he teams up with multiple champion jockey Anton Marcus, over a 1600m trip that should suit him perfectly.
Considering he was returning from a lengthy layoff, drawn appallingly and forced to run on from near last most recently, the fact he was only beaten two lengths by Brass Bell suggests he is a decent sort.
Now that he is beautifully drawn at No 3 and will strip a fitter horse, this son of Jackson should be very hard to peg back.
Bargain Bet
Race 8 No 2 Railtrip
Railtrip was believed to be a future star in the beginning of her career and although she didn’t live up to the hype, she looks good value for money today.
She caught the eye when runner-up last time out.
She was badly drawn on that occasion and it did not help that she was reported to be coughing in running. Even with all these disadvantages she fought all the way to the finish line and was beaten no more than a nose by Bank Robber.
Railtrip is actually unbeaten over this distance. If she brings her best form to the course, all those who remain faithful could be decently rewarded with a decent pay check.


Your Mecury Years age is:
Your Venus Years age is:
Your Earth Years age is:
Your Mars Years age is:
Your Jupiter Years age is:
Your Saturn Years age is:
Your Uranus Years age is:
Your Neptune Years age is:
Your Pluto Years age is:
Your earth LE is:


China should lower small banks' capital replenishment barriers - People's Daily
by Dhwani MehtaAccording to a commentary in the Chinese Communist Party’s official People’s Daily published on Monday, China’s financial regulators should lower barriers for small banks to replenish their capital, and develop more tools to help them raise funds, per Reuters.
The story read: “Regulators should consider designing diversified and differentiated means and indicators and implement differentiated regulation to better guide small and medium-sized banks forward on the road of differentiated development.”
Also Read
PBOC to inject more liquidity in December – China Press
China needs to prepare for zero interest rates - Global Times
Markets are expecting a lot of monetary as well as fiscal reforms from the Chinese authorities in an effort to stem the economic slowdown, in the face of the prolonged US-China trade war.


--- layout: post authors: ["Alistair Walsh"] title: "A Summary of Debriefing Feedback on Our Python Lesson" date: 2015-10-08 time: "01:00:00" tags: ["Lessons", "Python"] ---
Last month, we discussed results from a survey of how our instructors are teaching Python. We now have a summary of the feedback we've received in our bi-weekly debriefing meetings. The recurring themes are:
A greater choice of exercises and multiple choice questions would allow instructors to select domain specific examples and cater to varying levels of learner.
Some instructors added an explanation of the Jupyter notebook or Spyder IDE environments.
Some instructors added an explanation of basic Python datatypes before presenting the lessons.
Comments that there is too much material to fit into a workshop and that some sections seem rushed.
Request for a better explanation of the advantages of the Anaconda Distribution at the start of workshops and resources for post workshop learning.
Comments on presenters style were positive for funny and entertaining examples and negative for highly mathematical examples.
The details are listed below, with '+1' showing points that came up several times. We plan to use all of this when we redesign our basic Python lesson.
Changed lesson to be more relevant to audience1
Instructor used own examples to change emphasis of lesson to loops
Re-organised the flow of lesson
Explained differences between Bash, Python in the shell, Jupyter notebook
Short Jupyter Notebook introduction
Demonstrated Spyder IDE as well as Jupyter notebook
Basic data types explained before starting +1
More exercise options in repo +1
More multiple choice questions
Directions to post workshop resources needed
Explain that Anaconda will install in a separate folder and not affect existing Python
Testing section seemed rushed
Lesson material too long to fit workshop length +1
Jupyter Notebook
Using Jupyter Notebook with Git is challenging
Lack of extensive history in notebook (compared to shell) hinders learners +1
Starting with an empty notebook better than using template code
Notebooks should be saved to repo in a cleared state, split up monolithic Jupyter Notebook (i.e. clear output) +1
implies not live coding.
Instructor Style
Complaint: prime numbers example too mathematical
Complaint: not enough discussion prior to challenges. (Learners: "I don't know where to start!")
Compliment: funny anecdotes received well


---
layout: default-en
title: Codemotion Spain - Call for papers
---
{% include menu-en.html active="c4p" topbarClass="fixed" %}
Do you want to share what makes you excited about technology? Enter our Call for Papers open until July 31 and post your talk or workshop.
This is our first time that we will open 5 slots for startups in Codemotion. Read more.
Call for papers
Call for startups
These are the communities that will evaluate your talk. You should dedicate a minute to meet them and choose the best three to address your proposal.
Missing your community? Ask for an invitation here


{# INDIVIDUAL VIEW FOR EACH notablework #}
{# You can find a full list of variables to use on this page in your CMS. #}
{% extends "templates/partials/base.html" %}
{% block content %}
Create Date:
{# Format the date. You can use PHP's date function to format as needed. http://php.net/manual/en/function.date.php #}
{{ item.create_date|date('F d Y') }}
Last Updated:
{# Format the date. You can use PHP's date function to format as needed. http://php.net/manual/en/function.date.php #}
{{ item.last_updated|date('F d Y') }}
Publish Date:
{# Format the date. You can use PHP's date function to format as needed. http://php.net/manual/en/function.date.php #}
{{ item.publish_date|date('F d Y') }}
Sort order:
{{ item.sort_order }}
Time period:
{{ item.time_period }}
Link:
{{ item.link }}
Gallery:
{# List all images from this gallery. #}
{% for image in item.gallery %}
{# You can get the raw image url by accessing image.url #}


Players Schema
module:models/players/players-schema
Exports the players module
Parameters:
| Name | Type | Description |
|---|---|---|
players |
object |
Members
(inner, constant) players
Function that takes in an object that defines the properties and required data types for the player object


class: center, middle, inverse, title-slide # Week 12 - Functions and Iteration ### Joshua Rosenberg and Alex Lishinski ### April 8, 2021 --- # Welcome! Welcome to *week 12*! **Record the meeting** --- # Breakout rooms! Starting with whomever has the most plans for summer . . . - What aspects of the model formulas in R do you feel like you don't understand yet after reading the chapter? Prepare one-three responses to each of the above questions to share with the whole class! https://www.tmwr.org/base-r.html --- ## A recap of last week (on modeling) - A model is a simplification (and a summary) of your way - A common type of model is a regression model, aka a linear regression model (or a linear model) This code represents the regression of `hp` upon `mpg`: ```r lm(mpg ~ hp, data = my_data) ``` This code often corresponds to the underlying mathematical/statistical equation: $$ \operatorname{mpg} = \alpha + \beta_{1}(\operatorname{hp}) + \epsilon $$ --- ## A recap of last week (on modeling) - A linear model can help you learn how one or more _independent variables_ (or, _x_ variables) relate to one _dependent variable_ (a _y_ variable) - It is common to specify a number of models, and to compare them (commonly based on how much of the variation in the dependent variable is accounted for by relationships with the _x_ variable(s)) - the `lm()` function is a great tool for specifying relatively simple linear regression models, but it can be extended in a number of powerful ways - R has a number of tools for interpreting and presenting the output of models --- ## Checking-in on final projects - Overall feedback: Good work! - And, generally, please consider a) the scope of your project and b) the level of detail in your plans - We want you to do a small(er) number of things well - and in a way that positions you for your next project - Please revise your plan in response to our feedback over the next week --- ## Homework highlights A brief description of chunk options! --- ### Topics for today **Record the meeting** A. Functions B. Iteration (or, _applying_ functions) (C. On creating maps using ggplot2) --- ### A. Functions A function is a collection of code that: - takes one or more inputs (most commonly in R, data!) - and produces one or more forms of output (often, your data---transformed!) You _already_ use functions all of the time: ```r mpg ``` ``` ## # A tibble: 234 x 11 ## manufacturer model displ year cyl trans drv cty hwy fl class ## <chr> <chr> <dbl> <int> <int> <chr> <chr> <int> <int> <chr> <chr> ## 1 audi a4 1.8 1999 4 auto(l… f 18 29 p comp… ## 2 audi a4 1.8 1999 4 manual… f 21 29 p comp… ## 3 audi a4 2 2008 4 manual… f 20 31 p comp… ## 4 audi a4 2 2008 4 auto(a… f 21 30 p comp… ## 5 audi a4 2.8 1999 6 auto(l… f 16 26 p comp… ## 6 audi a4 2.8 1999 6 manual… f 18 26 p comp… ## 7 audi a4 3.1 2008 6 auto(a… f 18 27 p comp… ## 8 audi a4 quat… 1.8 1999 4 manual… 4 18 26 p comp… ## 9 audi a4 quat… 1.8 1999 4 auto(l… 4 16 25 p comp… ## 10 audi a4 quat… 2 2008 4 manual… 4 20 28 p comp… ## # … with 224 more rows ``` --- ### A. Functions **`select()` is a function** ```r mpg %>% select(model, displ, cyl) ``` ``` ## # A tibble: 234 x 3 ## model displ cyl ## <chr> <dbl> <int> ## 1 a4 1.8 4 ## 2 a4 1.8 4 ## 3 a4 2 4 ## 4 a4 2 4 ## 5 a4 2.8 6 ## 6 a4 2.8 6 ## 7 a4 3.1 6 ## 8 a4 quattro 1.8 4 ## 9 a4 quattro 1.8 4 ## 10 a4 quattro 2 4 ## # … with 224 more rows ``` --- ### A. Functions **`select()` and `filter()` are functions** ```r mpg %>% select(model, displ, cyl) %>% filter(cyl == 6) ``` ``` ## # A tibble: 79 x 3 ## model displ cyl ## <chr> <dbl> <int> ## 1 a4 2.8 6 ## 2 a4 2.8 6 ## 3 a4 3.1 6 ## 4 a4 quattro 2.8 6 ## 5 a4 quattro 2.8 6 ## 6 a4 quattro 3.1 6 ## 7 a4 quattro 3.1 6 ## 8 a6 quattro 2.8 6 ## 9 a6 quattro 3.1 6 ## 10 malibu 3.1 6 ## # … with 69 more rows ``` --- ### A. Functions There are all kinds of functions: ```r mpg %>% summarize(mean_cty = mean(cty), mean_hwy = mean(hwy)) ``` ``` ## # A tibble: 1 x 2 ## mean_cty mean_hwy ## <dbl> <dbl> ## 1 16.9 23.4 ``` ```r ten_mpg_values <- c(13, 63, 23, 43, 23, 33, 42, 34, 21, 23) mean(ten_mpg_values) ``` ``` ## [1] 31.8 ``` --- ### A. Functions You can write your own functions! Suppose we want to write a function to _standardize_ the `cty` variable to have _M_ = 0 and _SD_ = 1; presently, its *M* and *SD* are: ```r mpg %>% summarize(mean_cty = mean(cty), sd_cty = sd(cty)) ``` ``` ## # A tibble: 1 x 2 ## mean_cty sd_cty ## <dbl> <dbl> ## 1 16.9 4.26 ``` --- ### A. Functions (In this case, there _is_ an existing function, but it has some quirks, including, importantly, returning a _matrix_, rather than a vector/"a column") So, let's write our own. Here is a template, with two "blanks" represented by "___": ```r standardize_a_variable <- function(___) { ___ } ``` --- ### A. Functions **A not very useful function!** ```r standardize_variable <- function(variable) { variable } ``` ```r mpg %>% mutate(cty_std = standardize_variable(cty)) %>% summarize(mean_cty_std = mean(cty_std), sd_cty_std = sd(cty_std)) ``` ``` ## # A tibble: 1 x 2 ## mean_cty_std sd_cty_std ## <dbl> <dbl> ## 1 16.9 4.26 ``` --- ### A. Functions **A useful `standardize_variable`** ```r standardize_variable <- function(variable) { variable <- variable - mean(variable) # transforms variable to have M = 0 variable <- variable / sd(variable) # transforms variable to have SD = 1 variable } ``` ```r mpg %>% mutate(cty_std = standardize_variable(cty)) %>% summarize(mean_cty_std = mean(cty_std), sd_cty_std = sd(cty_std)) ``` ``` ## # A tibble: 1 x 2 ## mean_cty_std sd_cty_std ## <dbl> <dbl> ## 1 2.98e-16 1 ``` --- ### A. Functions **Let's double-check that the mean is practically equal to 0** (by rounding to precision to three decimal points) ```r mpg %>% mutate(cty_std = standardize_variable(cty)) %>% summarize(mean_cty_std = mean(cty_std), sd_cty_std = sd(cty_std)) %>% mutate(mean_cty_std_rounded = round(mean_cty_std, 3)) ``` ``` ## # A tibble: 1 x 3 ## mean_cty_std sd_cty_std mean_cty_std_rounded ## <dbl> <dbl> <dbl> ## 1 2.98e-16 1 0 ``` --- ### A. Functions We can add an argument to a function to modify how it works. ```r standardize_variable <- function(variable, remove_na_values = FALSE) { variable <- variable - mean(variable, na.rm = remove_na_values) variable <- variable / sd(variable, na.rm = remove_na_values) variable } ``` --- ### A. Functions What if we wanted to scale the variables cty, hwy, and cyl? Imagine that cyl has a missing (`NA`) value. ```r mpg %>% mutate(cty_std = standardize_variable(cty), hwy_std = standardize_variable(hwy), cyl_std = standardize_variable(cyl, remove_na_values = TRUE)) %>% select(cty_std, hwy_std, cyl_std, everything()) # bring the new variables to the beginning of the data frame ``` ``` ## # A tibble: 234 x 14 ## cty_std hwy_std cyl_std manufacturer model displ year cyl trans drv ## <dbl> <dbl> <dbl> <chr> <chr> <dbl> <int> <int> <chr> <chr> ## 1 0.268 0.934 -1.17 audi a4 1.8 1999 4 auto(l… f ## 2 0.973 0.934 -1.17 audi a4 1.8 1999 4 manual… f ## 3 0.738 1.27 -1.17 audi a4 2 2008 4 manual… f ## 4 0.973 1.10 -1.17 audi a4 2 2008 4 auto(a… f ## 5 -0.202 0.430 0.0689 audi a4 2.8 1999 6 auto(l… f ## 6 0.268 0.430 0.0689 audi a4 2.8 1999 6 manual… f ## 7 0.268 0.598 0.0689 audi a4 3.1 2008 6 auto(a… f ## 8 0.268 0.430 -1.17 audi a4 quat… 1.8 1999 4 manual… 4 ## 9 -0.202 0.262 -1.17 audi a4 quat… 1.8 1999 4 auto(l… 4 ## 10 0.738 0.766 -1.17 audi a4 quat… 2 2008 4 manual… 4 ## # … with 224 more rows, and 4 more variables: cty <int>, hwy <int>, fl <chr>, ## # class <chr> ``` --- ### A. Functions In summary: - You already use functions all of the time - You can write your own functions that take one or more types of input and return output - The functions that you are using within R were written by other people! - https://github.com/tidyverse/dplyr/blob/master/R/select.R - https://github.com/SurajGupta/r-source/blob/master/src/library/stats/R/median.R - https://github.com/jrosen48/konfound - https://github.com/data-edu/tidyLPA - If you find yourself copying and pasting the same code, it may be worthwhile to encapsulate your code within a function (more on this in a moment!) --- ### B. Iteration Iteration is another name for your computer carrying out some step(s) multiple times.  For example, one of us recently needed to download 14 surveys for a teacher professional development-focused research project, https://megabitess.org! There is a great package, qualtRics, which can help with this, but it's tedious to have to download the surveys one-by-one. The map functions can help with this. Let's hop over to `qualtrics-example.R` --- ### C. Mapping with ggplot2 A brief introduction for those interested, focused on the sf R package: https://joshuamrosenberg.com/post/2020/06/08/basic-sf-functionality-for-analyzing-and-plotting-geospatial-data/ --- # Logistics **This week** * Homework 12: Available tomorrow by noon; **Due by Thursday, 4/15** * Reading: * Longitudinal analysis: https://datascienceineducation.com/c10.html --- ## Schedule - The product for your final project and a recording that will serve as your presentation of it are both due by the end of the day on May 5 - *There is no portfolio!* - Exam 3 will be available April 15, due before class on April 22 - The revised data ethics statement is due April 29 (*changed*) - The curating a resource assignment is due by the same date/time as the final project - May 5 --- # Assignment updates * [Final project](https://making-data-science-count.github.io/s21-intro-to-data-sci-methods-in-ed/assignments-final-projects.html) * Responding to feedback * We recommend having starting in earnest within the next one-two weeks * [Curating a data science resource](https://making-data-science-count.github.io/s21-intro-to-data-sci-methods-in-ed/assignment-curating-a-data-science-resource.html) --- ### Random * Do you have an interest in a class on social network analysis (more of a general theoretical and methodological approach that can be brought to bear on the analysis of face-to-face and digital networks) and the analysis of social media data? If so, please let us know. * Are you interested in a graduate-level certificate in educational data science? * https://docs.google.com/document/d/e/2PACX-1vRhJTuCQfpEx9uZl57pucjyr_quIR9Vv5ZZdxvu4GSrdD5lkIQyUTsWX5NyuHiPivvOMPtkLmoLoi1X/pub --- ### Wrapping up In your base group's Slack channel: - What is one thing you learned today? - What is something you want to learn more about? - Share your feelings in GIF form!


--- layout: post title: 101102 l 11월 date: 2010-11-02 13:50:00.000000000 +09:00 type: post parent_id: '0' published: true password: '' status: publish categories: [] tags: - p. meta: _original_post_id: '40026041' _original_import_author: sheepless_ original_post_id: '40026041' _wp_old_slug: '40026041' author: login: mouthless email<EMAIL_ADDRESS>display_name: mouthless first_name: '' last_name: '' ---


This is a sample NodeJS application can be deployed on Heroku or run local. It's a simple Node Express app - that is good foundation for understanding how to get web apps Authenticated with the Web Server OAuth Authentication Flow on the Salesfroce Lightning & Heroku platforms.
Login With Salesforce Production Login With Salesforce Sanbox Source on GitHubgit clone https://github.com/iandrosov/sf-oauth-node-example
- this will create a local copy of the source code for the appcd sf-oauth-node-example
- change directory into the local source code repositoryheroku git:remote -a <your-app-name>
- associate the Heroku app with the repository


Color theme¶
If you feel like viewing the data in a different mood, it’s time to change the color scheme of the project.
Change theme¶
In the theme page, you can change the background color, empahasis color and the type of theme. The bulma framework is used in this project, the whole color scheme will be changed through bulma and bulmaswatch. Click update to update the appearance of all pages by the input settings.
- Color
This means that background color of all pages.
- Label
This means that font color of main elements such as title, label, section name. White is recommended when the background color is set to dark, black when set to white.
- Emphasis
This means that text color to be emphasized. Yellow is recommended when the background color is set to dark, Red when set to white.
- Theme
This means that color theme defined by bulmaswatch. Refer bulmaswatch page to see how each theme look like.
Samples of each theme with dark color are as follows.