lecture 11: last lecture: putting things...
TRANSCRIPT
Admin G/B/U Tying Tying R: Functions
Lecture 11:Last Lecture: Putting Things Together
April 23, 2018
Admin G/B/U Tying Tying R: Functions
Overview
Course Administration
Good, Bad and Ugly
Tying Things Together: Stories
Tying Things Together: Visualizations that Communicate
R Functions
Admin G/B/U Tying Tying R: Functions
Course Administration
1. Presentations next week
2. Policy brief and presentation handout
3. Updated (?) grades online
4. Online evaluations open! Please give feedback
5. Missing anything from me?
Admin G/B/U Tying Tying R: Functions
Today’s Final Good Bad and Ugly
• Alex Sexton
Admin G/B/U Tying Tying R: Functions
Alex’s Chart
From https://howmuch.net/articles/international-trade-as-a-share-of-state-GDP
Admin G/B/U Tying Tying R: Functions
Knaflic: Graphics to Tell Stories
Admin G/B/U Tying Tying R: Functions
Knaflic’s 5 Case Studies
1. Color considerations with a dark background
2. Leveraging animation in the visuals you present
3. Establishing logic in order
4. Strategies for avoiding the spaghetti graph
5. Alternatives to pie charts
Wording is all Knaflic’s.
Admin G/B/U Tying Tying R: Functions
Knaflic’s 5 Case Studies
1. Color considerations with a dark background
2. Leveraging animation in the visuals you present
3. Establishing logic in order
4. Strategies for avoiding the spaghetti graph
5. Alternatives to pie charts
Wording is all Knaflic’s.
Admin G/B/U Tying Tying R: Functions
2. Animation
• Don’t use animation – figures that move without yourguidance
• Do use sequential reveal
• Great example of same figure in presentation and paper
Admin G/B/U Tying Tying R: Functions
How Do You Get People to Pay Attention to theImportant Parts?
Admin G/B/U Tying Tying R: Functions
Frame the Analysis
Admin G/B/U Tying Tying R: Functions
Start at the Beginning
Admin G/B/U Tying Tying R: Functions
Add Step by Step
Admin G/B/U Tying Tying R: Functions
Step by Step
Admin G/B/U Tying Tying R: Functions
Step by Step
Admin G/B/U Tying Tying R: Functions
Till the End
Admin G/B/U Tying Tying R: Functions
And For Print
Admin G/B/U Tying Tying R: Functions
3. Logic in order
• Highlight what you want people to focus on
• With order
• With color
• With text
Admin G/B/U Tying Tying R: Functions
What’s Important Here?
Admin G/B/U Tying Tying R: Functions
Suppose We Care Most About User Satisfaction
Admin G/B/U Tying Tying R: Functions
Suppose We Care Most About User Dissatisfaction
Admin G/B/U Tying Tying R: Functions
Or About Which Feature is Least Used
Admin G/B/U Tying Tying R: Functions
What if You Want to Highlight All Three?
Admin G/B/U Tying Tying R: Functions
What if You Want to Highlight All Three?
Admin G/B/U Tying Tying R: Functions
Highlighting All Three, Part 2
Admin G/B/U Tying Tying R: Functions
Highlighting All Three, Part 3
Admin G/B/U Tying Tying R: Functions
Putting It All Together: Best for Print
Admin G/B/U Tying Tying R: Functions
4. No Spaghetti
• Instead of the book’s example, another from her website
• Transforming hard-to-read bars to easier-to-read formats
• Many similar ideas apply
Admin G/B/U Tying Tying R: Functions
Pew Charts on Number of Newly Married AdultsWhat’s Wrong and How to Fix?
Admin G/B/U Tying Tying R: Functions
Show Change Over Time
Admin G/B/U Tying Tying R: Functions
Can You Pick Out the Point Here?
Admin G/B/U Tying Tying R: Functions
Highlighting the Increase for You Guys
Admin G/B/U Tying Tying R: Functions
What Would You Want to Pull Out?
Admin G/B/U Tying Tying R: Functions
Highlighting Peak and Trough
Admin G/B/U Tying Tying R: Functions
Mulbrandon’s Graphics
Admin G/B/U Tying Tying R: Functions
Visualizing Economics
• Mulbrandon has a BA in economics, and a postgraduatedegree in design
• Experience in finance industry
• Now runs a data visualization firm
• To make this book she used Excel, OmniGraphSketcher (nolonger available), Illustrator, R and InDesign (publishing)
Admin G/B/U Tying Tying R: Functions
Which Techniques is She Using?
• What’s the story she’s trying to convey?
• Look at each graph and think about the underlying techniques
• Two static and two building
152 Sources: US Bureau of Labor Statistics, “100 Years of US Consumer Spending: Data for the Nation, New York City, and Boston,” Report no. 991 • US Census Bureau
Cost of Housing in the 20th Century
1975
1900 1910 1920 1930 1940 1950 1960 1970 1980 1990 2000
$20,000
0
5,000
10,000
15,000
2010
US
Dol
lars
with fewer people living together3.7 2.6
55% 99%
More homes had a full bathroom.
34 million 112 million
while the size of houses increased.Median square feet of �oor area
in new single-family houses
2,135~1,000
Hot and cold piped water,a bathtub or shower,
and a �ush toilet
1940 2000
More housing built for more people
Annual Cost of Housing Urban Areas Only, Adjusted for In�ation
Vietnam
T.Roosevelt
Taft
HardingCoolidge
Hoover
Eisenhower
Nixon
Ford
Reagan
G.H.W.Bush
G.W.Bush
Wilson
F.D.Roosevelt
Truman
Kennedy
L.B.Johnson
Carter
Clinton
Obama
Great Recession
Great Depression
WW I
WW II Cold WarKorean Persian
GulfAfghanistan Iraq
1901–2002
1040
Census
1040
Person
Household
Census
CBO
Census Bureau Income Earner
Census Bureau Household
Census Bureau Family
Congresstional Budget O�ce Household
IRS Returns
Household of unrelated people
Household of a single person
Household of a family & unrelated people
Family Household (unrelated people not included)
Tax Units Filing Jointly
1040 IRS Returns Filing Jointly
CIA Factbook
Family
Family Household
Family Household
Tax Unit
1040
IRS
IRS
CIA
Bureau of Economic AnalysisBEA
Bureau of Labor Statistics BLS
Bureau of Labor Statistics BLS
BLS
Multiple Sources Summary Statistics
Multiple Sources Individual Income
Vario
usVa
rious
Cens
us
VisualizingEconomics.comVisualizingEconomics.com
100 101Source: EMSI EconomicModeling.com (Compiled from data collected by BLS, BEA and US Census Bureau)
Wages of All Occupations by Education2011
1040
Census
1040
Person
Household
Census
CBO
Census Bureau Income Earner
Census Bureau Household
Census Bureau Family
Congresstional Budget O�ce Household
IRS Returns
Household of unrelated people
Household of a single person
Household of a family & unrelated people
Family Household (unrelated people not included)
Tax Units Filing Jointly
1040 IRS Returns Filing Jointly
CIA Factbook
Family
Family Household
Family Household
Tax Unit
1040
IRS
IRS
CIA
Bureau of Economic AnalysisBEA
Bureau of Labor Statistics BLS
Bureau of Labor Statistics BLS
BLS
Multiple Sources Summary Statistics
Multiple Sources Individual IncomeVa
rious
Vario
usCe
nsus
$90
0
10
20
30
40
50
60
70
80
Postal service mail carriers
Tellers
Door-to-door sales workers, news and street vendors, and related workers
Postal service clerks
Helpers, extraction workers
RiggersShuttle car operators
Bridge and lock tendersSailors and marine oilersProcurement clerks
F ile clerksOrder clerks
BartendersChild care workers
Dental assistants
Roofers
Laundry and dry-cleaning workers
Tax preparers
Pest control workers
Rotary drill operators, oil and gas
Floral designers
Wellhead pumpers
Tapers
Mining machine operators, all other
Fence erectors
Gas compressor and gas pumping station operators
Paperhangers
Roof bolters, mining
Models
Advertising sales agents
Medical secretaries
Legal secretaries
Medical transcriptionists
Commercial pilots
Library technicians
Gaming dealers
Barbers
Drafters, all other
Desktop publishers
Ship engineers
Carpenters
Farmers and ranchers
ElectriciansFire fighters
Coaches and scouts
Flight attendants
Actors
Upholsterers
Air tra�c controllers
Power plant operators
Job printers
Gas plant operators
Stonemasons
Craft artists
Dancers
Cooks, private household
Nuclear power reactor operators
Athletes and sports competitors
Food service managers
Real estate brokers
Industrial production managers
Cost estimators
Detectives and criminal investigators
Lodging managersChefs and head cooks
New accounts clerksGaming supervisors
Graders and sorters, agricultural products
Choreographers
Emergency management specialists
F ire inspectors and investigatorsAircraft cargo handling supervisors Paralegals and legal assistants
Interior designers
Diagnostic medical sonographers
Biological technicians
Geological and petroleum technicians
Chemical technicians
Veterinary technologists and technicians
Fashion designers
Nuclear medicine technologists
Radiation therapists
Forest and conservation techniciansSemiconductor processors
Forensic science technicians
First-line supervisors/managers of police and detectives
Speech-language pathologists
LibrariansInstructional coordinators
Occupational therapists
Clergy
Mental health counselors
Rehabilitation counselors
Geoscientists, except hydrologists and geographers
Urban and regional planners
Statisticians
Economists
Marriage and family therapists
Curators
Political scientists
Archivists
Operations research analysts
Loan o�cers
Civil engineers
Graphic designers
Engineers, all other
Airline pilots, copilots, and flight engineers
Writers and authors
Logisticians
Editors
Aerospace engineers
Computer hardware engineers
Sales engineers
Chemists
Multi-media artists and animators
Credit analysts
Dietitians and nutritionists
Petroleum engineers
Technical writers
Surveyors
Directors, religious activities and education
Nuclear engineers
Recreational therapists
Materials scientists
Set and exhibit designers
Chief executivesSales managers
Computer and information systems managers
Medical and health services managers
Marketing managers
Engineering managers
Administrative services managers
Producers and directors
Art directors
Vocational education teachers, secondary school
Public relations managers
Natural sciences managers
Advertising and promotions managers
Legislators
Music directors and composers
Education administrators, preschool and child care center/program
Arbitrators, mediators, and conciliators
Broadcast news analysts
Postsecondary teachers
Clinical, counseling, and school psychologists
Medical scientists, except epidemiologists
Computer and information scientists, research
Physicists
Microbiologists
Mathematicians
Physicians and surgeons
LawyersPharmacists
Dentists, general
Veterinarians
Chiropractors
Optometrists
Podiatrists
Orthodontists
Oral and maxillofacial surgeons
Dentists, all other specialists
Audiologists
Prosthodontists
Purchasing managers
Correspondence clerks
Chemical plant and system operators
Computer systems analysts
Electrical and electronics repairers, powerhouse, substation, and relay
First-line supervisors/managers of fire fighting and prevention workers
Short-term on-the-job training
Moderate-term on-the-job training
Postsecondary vocational award
Long-term on-the-job training
Work experience in a related field
Associate’s degree
Master’s degree
Bachelor’s degree
Degree plus work experience
Doctoral degree
Professional degree
Radio mechanics
Mechanical drafters
Estimated Annual Salary
$183,600
163,200
142,800
122,400
102,000
83,200
62,400
41,600
20,100
Median Hourly Wage (2011 US Dollars)
$90
0
10
20
30
40
50
60
70
80
Postal service mail carriers
Tellers
Door-to-door sales workers, news and street vendors, and related workers
Postal service clerks
Helpers, extraction workers
RiggersShuttle car operators
Bridge and lock tendersSailors and marine oilersProcurement clerks
F ile clerksOrder clerks
BartendersChild care workers
Dental assistants
Roofers
Laundry and dry-cleaning workers
Tax preparers
Pest control workers
Rotary drill operators, oil and gas
Floral designers
Wellhead pumpers
Tapers
Mining machine operators, all other
Fence erectors
Gas compressor and gas pumping station operators
Paperhangers
Roof bolters, mining
Models
Advertising sales agents
Medical secretaries
Legal secretaries
Medical transcriptionists
Commercial pilots
Library technicians
Gaming dealers
Barbers
Drafters, all other
Desktop publishers
Ship engineers
Carpenters
Farmers and ranchers
ElectriciansFire fighters
Coaches and scouts
Flight attendants
Actors
Upholsterers
Air tra�c controllers
Power plant operators
Job printers
Gas plant operators
Stonemasons
Craft artists
Dancers
Cooks, private household
Nuclear power reactor operators
Athletes and sports competitors
Food service managers
Real estate brokers
Industrial production managers
Cost estimators
Detectives and criminal investigators
Lodging managersChefs and head cooks
New accounts clerksGaming supervisors
Graders and sorters, agricultural products
Choreographers
Emergency management specialists
F ire inspectors and investigatorsAircraft cargo handling supervisors Paralegals and legal assistants
Interior designers
Diagnostic medical sonographers
Biological technicians
Geological and petroleum technicians
Chemical technicians
Veterinary technologists and technicians
Fashion designers
Nuclear medicine technologists
Radiation therapists
Forest and conservation techniciansSemiconductor processors
Forensic science technicians
First-line supervisors/managers of police and detectives
Speech-language pathologists
LibrariansInstructional coordinators
Occupational therapists
Clergy
Mental health counselors
Rehabilitation counselors
Geoscientists, except hydrologists and geographers
Urban and regional planners
Statisticians
Economists
Marriage and family therapists
Curators
Political scientists
Archivists
Operations research analysts
Loan o�cers
Civil engineers
Graphic designers
Engineers, all other
Airline pilots, copilots, and flight engineers
Writers and authors
Logisticians
Editors
Aerospace engineers
Computer hardware engineers
Sales engineers
Chemists
Multi-media artists and animators
Credit analysts
Dietitians and nutritionists
Petroleum engineers
Technical writers
Surveyors
Directors, religious activities and education
Nuclear engineers
Recreational therapists
Materials scientists
Set and exhibit designers
Chief executivesSales managers
Computer and information systems managers
Medical and health services managers
Marketing managers
Engineering managers
Administrative services managers
Producers and directors
Art directors
Vocational education teachers, secondary school
Public relations managers
Natural sciences managers
Advertising and promotions managers
Legislators
Music directors and composers
Education administrators, preschool and child care center/program
Arbitrators, mediators, and conciliators
Broadcast news analysts
Postsecondary teachers
Clinical, counseling, and school psychologists
Medical scientists, except epidemiologists
Computer and information scientists, research
Physicists
Microbiologists
Mathematicians
Physicians and surgeons
LawyersPharmacists
Dentists, general
Veterinarians
Chiropractors
Optometrists
Podiatrists
Orthodontists
Oral and maxillofacial surgeons
Dentists, all other specialists
Audiologists
Prosthodontists
Purchasing managers
Correspondence clerks
Chemical plant and system operators
Computer systems analysts
Electrical and electronics repairers, powerhouse, substation, and relay
First-line supervisors/managers of fire fighting and prevention workers
Short-term on-the-job training
Moderate-term on-the-job training
Postsecondary vocational award
Long-term on-the-job training
Work experience in a related field
Associate’s degree
Master’s degree
Bachelor’s degree
Degree plus work experience
Doctoral degree
Professional degree
Radio mechanics
Mechanical drafters
Estimated Annual Salary
$183,600
163,200
142,800
122,400
102,000
83,200
62,400
41,600
20,100
Median Hourly Wage (2011 US Dollars)
VisualizingEconomics.com
62
100%0 10 20 30 40 50 60 70 80 90
100%0 10 20 30 40 50 60 70 80 90
No High School Diploma
Bachelor's Degree or More
Some College or Associate’s Degree
High School Graduate
No Earners
Two Earners (or More)
One Earner
15 to 24 years
75 years and over
65 to 74 years
55 to 64 years
45 to 54 years
35 to 44 years
25 to 34 years
Urban (Inside principal cities)
Rural (Outside metro statisitcal areas)
Surburban (Outside principal cities)
Married-Couple Family
Singles/Unrelated People
No Spouse Present Family
Owner Occupied
Worked (Full- or Part-Time)
Did Not Work for Pay in 2010
Renter Occupied
White
Asian
Hispanic
Black
71%
13%
12%
4%
11%
28%
27%
28%
5%
17%
18%
20%
18%
11%
10%
24%38%
38%
48%
18%
35%
33%
50%
17%
65%
35%
65%
33%
Education of Householder
Race of Householder
Number of Earners in Household
Type of Household
Location of Household
Work History of Householder
Housing (Less than 2% do not pay cash rent )
Age of Householder
Source: US Census Bureau, 2006–2010 American Community Survey
Demographics of All Incomes2010
1040
Census10
40
Person
Household
Census
CBO
Census Bureau Income Earner
Census Bureau Household
Census Bureau Family
Congresstional Budget O�ce Household
IRS Returns
Household of unrelated people
Household of a single person
Household of a family & unrelated people
Family Household (unrelated people not included)
Tax Units Filing Jointly
1040 IRS Returns Filing Jointly
CIA Factbook
Family
Family Household
Family Household
Tax Unit
1040
IRS
IRS
CIA
Bureau of Economic AnalysisBEA
Bureau of Labor Statistics BLS
Bureau of Labor Statistics BLS
BLS
Multiple Sources Summary Statistics
Multiple Sources Individual Income
Vario
usVa
rious
Cens
us
VisualizingEconomics.comVisualizingEconomics.com
63
100%0 10 20 30 40 50 60 70 80 90
100%0 10 20 30 40 50 60 70 80 90
No High School Diploma
Bachelor's Degree or More
Some College or Associate’s Degree
High School Graduate
No Earners
Two Earners (or More)
One Earner
15 to 24 years
75 years and over
65 to 74 years
55 to 64 years
45 to 54 years
35 to 44 years
25 to 34 years
Urban (Inside principal cities)
Rural (Outside metro statisitcal areas)
Surburban (Outside principal cities)
Married-Couple Family
Singles/Unrelated People
No Spouse Present Family
Owner Occupied
Worked (Full- or Part-Time)
Did Not Work for Pay in 2010
Renter Occupied
White
Asian
Hispanic
Black
63%
19%
15%
3%
22%
34%
23%
13%
9%
15%
13%
15%
16%
14%
19%
52%39%
8%
23%
23%
54%
38%
42%
20%
40%
60%
47%
50%
All Households
$30,000
Education of Householder
Race of Householder
Number of Earners in Household
Type of Household
Location of Household
Work History of Householder
Housing (Less than 2% do not pay cash rent )
Age of Householder
Source: US Census Bureau, 2006–2010 American Community Survey
Demographics of Incomes below $30,0002010
1040
Census10
40
Person
Household
Census
CBO
Census Bureau Income Earner
Census Bureau Household
Census Bureau Family
Congresstional Budget O�ce Household
IRS Returns
Household of unrelated people
Household of a single person
Household of a family & unrelated people
Family Household (unrelated people not included)
Tax Units Filing Jointly
1040 IRS Returns Filing Jointly
CIA Factbook
Family
Family Household
Family Household
Tax Unit
1040
IRS
IRS
CIA
Bureau of Economic AnalysisBEA
Bureau of Labor Statistics BLS
Bureau of Labor Statistics BLS
BLS
Multiple Sources Summary Statistics
Multiple Sources Individual Income
Vario
usVa
rious
Cens
us
VisualizingEconomics.com
26 Sources: AR: Absolute Return + Alpha, “The Rich List,” April 2011 • Forbes, “Celebrity 100, 2011” • Forbes, “CEO Compensation, 2011.” • USA Today, “USATODAY Salaries Databases”
Top Major League Baseball Salaries
$32 million
$0
$4 million
$8 million
$12 million
$16 million
$20 million
$24 million
$28 million
Alex Rodriguez
Vernon Wells
CC Sabathia
Mark Teixeira
Joe Mauer
Johan Santana
Todd Helton
Miguel Cabrera
Roy Halladay
Ryan Howard
Carlos Beltran
Carlos Lee
Alfonso Soriano
Carlos Zambrano
Torii Hunter
Barry Zito
Jason Bay
Ichiro Suzuki
Josh Beckett
A.J. Burnett
Matt Holliday
Michael Young
Roy Oswalt
Jake Peavy
John Lackey
Baseball Players
CEOs of Publicly Traded Companies
IBMStarbucks
Average Salary of All Major League Players 2010 ($3.3 million)
Salary only, does not include endorsements
2010
1040
Census
1040
Person
Household
Census
CBO
Census Bureau Income Earner
Census Bureau Household
Census Bureau Family
Congresstional Budget O�ce Household
IRS Returns
Household of unrelated people
Household of a single person
Household of a family & unrelated people
Family Household (unrelated people not included)
Tax Units Filing Jointly
1040 IRS Returns Filing Jointly
CIA Factbook
Family
Family Household
Family Household
Tax Unit
1040
IRS
IRS
CIA
Bureau of Economic AnalysisBEA
Bureau of Labor Statistics BLS
Bureau of Labor Statistics BLS
BLS
Multiple Sources Summary Statistics
Multiple Sources Individual IncomeVa
rious
Vario
usCe
nsus
VisualizingEconomics.comVisualizingEconomics.com
27Sources: AR: Absolute Return + Alpha, “The Rich List,” April 2011 • Forbes, “Celebrity 100, 2011” • Forbes, “CEO Compensation, 2011.” • USA Today, “USATODAY Salaries Databases”
Top CEO Compensation2010
1040
Census
1040
Person
Household
Census
CBO
Census Bureau Income Earner
Census Bureau Household
Census Bureau Family
Congresstional Budget O�ce Household
IRS Returns
Household of unrelated people
Household of a single person
Household of a family & unrelated people
Family Household (unrelated people not included)
Tax Units Filing Jointly
1040 IRS Returns Filing Jointly
CIA Factbook
Family
Family Household
Family Household
Tax Unit
1040
IRS
IRS
CIA
Bureau of Economic AnalysisBEA
Bureau of Labor Statistics BLS
Bureau of Labor Statistics BLS
BLS
Multiple Sources Summary Statistics
Multiple Sources Individual Income
Vario
usVa
rious
Cens
us
$100 million
$0
$10 million
$20 million
$30 million
$40 million
$50 million
$60 million
$70 million
$80 million
$90 million
Baseball Players
UnitedHealth Group
Qwest Communications
Walt Disney
Express Scripts
Coach
Polo Ralph Lauren
Gilead Sciences
Anadarko Petroleum
Cisco Systems
Verizon
AllerganLife Technologies
Noble Energy
McKesson
EMCNvidia
Peabody Energy
Cimarex Energy
IBM Philip Morris Intl
Ultra Petroleum
Starbucks
Yum Brands
DaVitaEmerson
Electric
CEOs of Publicly Traded Companies
Celebrities
Jerry Seinfeld
Bethenny Frankel
James Patterson
VisualizingEconomics.com
28 Sources: AR: Absolute Return + Alpha, “The Rich List,” April 2011 • Forbes, “Celebrity 100, 2011” • Forbes, “CEO Compensation, 2011.” • USA Today, “USATODAY Salaries Databases”
Top Celebrity Income2010
1040
Census
1040
Person
Household
Census
CBO
Census Bureau Income Earner
Census Bureau Household
Census Bureau Family
Congresstional Budget O�ce Household
IRS Returns
Household of unrelated people
Household of a single person
Household of a family & unrelated people
Family Household (unrelated people not included)
Tax Units Filing Jointly
1040 IRS Returns Filing Jointly
CIA Factbook
Family
Family Household
Family Household
Tax Unit
1040
IRS
IRS
CIA
Bureau of Economic AnalysisBEA
Bureau of Labor Statistics BLS
Bureau of Labor Statistics BLS
BLS
Multiple Sources Summary Statistics
Multiple Sources Individual IncomeVa
rious
Vario
usCe
nsus
$300 million
$0
$50 million
$100 million
$150 million
$200 million
$250 million
CEOs of Publicly Traded Companies
Baseball Players
Hedge Fund Managers
Celebrities
Oprah Winfrey
U2
Tyler Perry
Bon Jovi
Jerry Bruckheimer
Steven Spielberg
Elton John
Lady Gaga
Simon Cowell
James Patterson
Dr. Phil McGraw
Leonardo Dicaprio
Howard Stern
Tiger Woods
Dick Wolf
Jerry Seinfeld
James Cameron
Paul McCartney
Rush Limbaugh
Black Eyed Peas
Ryan Seacrest
Donald Trump
Bethenny Frankel
Kobe Bryant
Justin Bieber
VisualizingEconomics.comVisualizingEconomics.com
29Sources: AR: Absolute Return + Alpha, “The Rich List,” April 2011 • Forbes, “Celebrity 100, 2011” • Forbes, “CEO Compensation, 2011.” • USA Today, “USATODAY Salaries Databases”
Top Hedge Fund Manager Income
$5 billion
$1 billion
$2 billion
$3 billion
$4 billion
$0
John Paulson
Ray Dalio
James Simons
David Tepper
Steve Cohen
Eddie Lampert
Carl Icahn
Bruce Kovner
George Soros
Paul Tudor Jones II
Ken Gri�n
Michael Hintze
Marc Lasry
Willian Ackman
Dan Och
Izzy Englander
David Shaw
Michael Platt
Stanley Druckenmiller
Andrew Hoine
Seth Klarman
Leon Cooperman
Louis Bacon
Jamie Dinan
Dan Loeb
CEOsBaseball Players
Celebrities
Hedge Fund Managers
2010
1040
Census
1040
Person
Household
Census
CBO
Census Bureau Income Earner
Census Bureau Household
Census Bureau Family
Congresstional Budget O�ce Household
IRS Returns
Household of unrelated people
Household of a single person
Household of a family & unrelated people
Family Household (unrelated people not included)
Tax Units Filing Jointly
1040 IRS Returns Filing Jointly
CIA Factbook
Family
Family Household
Family Household
Tax Unit
1040
IRS
IRS
CIA
Bureau of Economic AnalysisBEA
Bureau of Labor Statistics BLS
Bureau of Labor Statistics BLS
BLS
Multiple Sources Summary Statistics
Multiple Sources Individual IncomeVa
rious
Vario
usCe
nsus
VisualizingEconomics.com
Admin G/B/U Tying Tying R: Functions
Tying Things Together: Functions in R
Admin G/B/U Tying Tying R: Functions
From Animate to Automate
• Today’s R tutorial: functions
• How to automate repetitive tasks
• Usually slower in the short run
• Faster in the long run
• Less error prone
Admin G/B/U Tying Tying R: Functions
Functions Plan
• Introduce a simple function in class
• Tutorial takes to you automating graph production
Defining a Function
function.name <- function(arg1, arg2){# stuff your function does
}
I function.name: what you call the functionI function: needed to tell R this is a functionI arg1: first argument of the functionI inside the curly braces: what you want the function to do
Simple Function Example
summer <- function(x,y){x^y
}
I function name?I arguments?I body of the function?
Calling a Function
summer <- function(x,y){x^y
}
summer(x=2,y=3)
## [1] 8
summer(3,2)
## [1] 9
Calling a Function
summer <- function(x,y){x^y
}
summer(x=2,y=3)
## [1] 8
summer(3,2)
## [1] 9
Calling a Function
summer <- function(x,y){x^y
}
summer(x=2,y=3)
## [1] 8
summer(3,2)
## [1] 9
Calling a Function
summer <- function(x,y){x^y
}
summer(x=2,y=3)
## [1] 8
summer(3,2)
## [1] 9
Admin G/B/U Tying Tying R: Functions
To the Tutorial!
• Good luck
• Do the evaluation
• Presentations next week