SlideShare a Scribd company logo
1 of 6
Split-Apply-Combine Strategy with the Package plyr

Hadley Wickham. The split-apply-combine strategy for data
 analysis. Journal of Statistical Software, 40(1):1–29, 2011.
           URL http://www.jstatsoft.org/v40/i01/.

                   http://plyr.had.co.nz/
Common action in statistical analyses:
• Split up a dataset into pieces
• Apply a function to these pieces
• Combine output and examine the results

Examples:
• Calculate the mean of response by treatment
• Run ANOVA on numerous response variables
• Calculate total precipitation from weather data by
  month or year
plyr offers:
• a streamlined, simplified, and unified framework and
   alterative to the R ‘apply’ base functions (apply, sapply, tapply,
   lapply, mapply, etc.)
• a streamlined and simplified approach to writing for loops

When not to use plyr:
• each iteration requires overlapping data (e.g., running mean)
• each iteration depends on the previous iteration (e.g.,
  dynamic simulation)
The package plyr uses a similar command **ply
• where the 1st ‘*’ designates the input type
• 2nd ‘*’ designates the output type.

The choices for the ‘*’ are either, ‘a’, ‘d’, ‘l’, or ’_’
• a = array
• d = data frame
• l = list
• _ means the output is discarded

• Examples:
   – ddply = input is a dataframe, output is a data frame
   – alply = input is an array, output is a list
• Full function: ddply(.data, .variables, .fun, ..., )

• .data = R object that will be split up, processed and
  recombined
• .variables (.margins for arrays) = describes how to split up the
  input into pieces
• .fun, = the processing function, and is applied to each piece in
  turn.
• All further arguments are passed on to the processing
  function.
• If you omit .fun the individual pieces will not be modified, but
  the entire data structure will be converted from one type to
  another.
The package plyr uses a similar command style: **ply
• where the 1st ‘*’ designates the input type
• 2nd ‘*’ designates the output type.

The choices for the ‘*’ are either, ‘a’, ‘d’, ‘l’, or ’_’
• a = array
• d = data frame
• l = list
• _ = the output is discarded

• Examples:
   – ddply = input is a data frame, output is a data frame
   – alply = input is an array, output is a list

More Related Content

What's hot

Data structure and algorithm All in One
Data structure and algorithm All in OneData structure and algorithm All in One
Data structure and algorithm All in Onejehan1987
 
Introduction of data structure
Introduction of data structureIntroduction of data structure
Introduction of data structureeShikshak
 
Basic of Data Structure - Data Structure - Notes
Basic of Data Structure - Data Structure - NotesBasic of Data Structure - Data Structure - Notes
Basic of Data Structure - Data Structure - NotesOmprakash Chauhan
 
Whats new in Process Simulator 2016 sp1?
Whats new in Process Simulator 2016 sp1?Whats new in Process Simulator 2016 sp1?
Whats new in Process Simulator 2016 sp1?ProModel Corporation
 
Presentation on Elementary data structures
Presentation on Elementary data structuresPresentation on Elementary data structures
Presentation on Elementary data structuresKuber Chandra
 
Abstract data types
Abstract data typesAbstract data types
Abstract data typesHoang Nguyen
 
ProModel MedModel 2016 sp1 What's New?
ProModel MedModel 2016 sp1 What's New?ProModel MedModel 2016 sp1 What's New?
ProModel MedModel 2016 sp1 What's New?ProModel Corporation
 
Data structure and algorithm using java
Data structure and algorithm using javaData structure and algorithm using java
Data structure and algorithm using javaNarayan Sau
 
ADS Introduction
ADS IntroductionADS Introduction
ADS IntroductionNagendraK18
 
Python advanced 3.the python std lib by example – algorithm
Python advanced 3.the python std lib by example – algorithmPython advanced 3.the python std lib by example – algorithm
Python advanced 3.the python std lib by example – algorithmJohn(Qiang) Zhang
 
Python advanced 3.the python std lib by example –data structures
Python advanced 3.the python std lib by example –data structuresPython advanced 3.the python std lib by example –data structures
Python advanced 3.the python std lib by example –data structuresJohn(Qiang) Zhang
 
Cost estimation for Query Optimization
Cost estimation for Query OptimizationCost estimation for Query Optimization
Cost estimation for Query OptimizationRavinder Kamboj
 

What's hot (20)

Stack and Heap
Stack and HeapStack and Heap
Stack and Heap
 
Data structure and algorithm All in One
Data structure and algorithm All in OneData structure and algorithm All in One
Data structure and algorithm All in One
 
Query trees
Query treesQuery trees
Query trees
 
Introduction of data structure
Introduction of data structureIntroduction of data structure
Introduction of data structure
 
Lecture 1 and 2
Lecture 1 and 2Lecture 1 and 2
Lecture 1 and 2
 
Basic of Data Structure - Data Structure - Notes
Basic of Data Structure - Data Structure - NotesBasic of Data Structure - Data Structure - Notes
Basic of Data Structure - Data Structure - Notes
 
Whats new in Process Simulator 2016 sp1?
Whats new in Process Simulator 2016 sp1?Whats new in Process Simulator 2016 sp1?
Whats new in Process Simulator 2016 sp1?
 
Presentation on Elementary data structures
Presentation on Elementary data structuresPresentation on Elementary data structures
Presentation on Elementary data structures
 
Abstract data types
Abstract data typesAbstract data types
Abstract data types
 
Functions with heap and stack
Functions with heap and stackFunctions with heap and stack
Functions with heap and stack
 
ProModel MedModel 2016 sp1 What's New?
ProModel MedModel 2016 sp1 What's New?ProModel MedModel 2016 sp1 What's New?
ProModel MedModel 2016 sp1 What's New?
 
Sorting
SortingSorting
Sorting
 
Queues
QueuesQueues
Queues
 
Data Structures 01
Data Structures 01Data Structures 01
Data Structures 01
 
Data structure and algorithm using java
Data structure and algorithm using javaData structure and algorithm using java
Data structure and algorithm using java
 
ADS Introduction
ADS IntroductionADS Introduction
ADS Introduction
 
Python advanced 3.the python std lib by example – algorithm
Python advanced 3.the python std lib by example – algorithmPython advanced 3.the python std lib by example – algorithm
Python advanced 3.the python std lib by example – algorithm
 
Queue
QueueQueue
Queue
 
Python advanced 3.the python std lib by example –data structures
Python advanced 3.the python std lib by example –data structuresPython advanced 3.the python std lib by example –data structures
Python advanced 3.the python std lib by example –data structures
 
Cost estimation for Query Optimization
Cost estimation for Query OptimizationCost estimation for Query Optimization
Cost estimation for Query Optimization
 

Similar to Intro to plyr for Davis R Users' Group, by Steve Culman

358 33 powerpoint-slides_4-introduction-data-structures_chapter-4
358 33 powerpoint-slides_4-introduction-data-structures_chapter-4358 33 powerpoint-slides_4-introduction-data-structures_chapter-4
358 33 powerpoint-slides_4-introduction-data-structures_chapter-4sumitbardhan
 
Data Structures in C
Data Structures in CData Structures in C
Data Structures in CJabs6
 
Functional Programming.pptx
Functional Programming.pptxFunctional Programming.pptx
Functional Programming.pptxKarthickT28
 
Data Structure & aaplications_Module-1.pptx
Data Structure & aaplications_Module-1.pptxData Structure & aaplications_Module-1.pptx
Data Structure & aaplications_Module-1.pptxGIRISHKUMARBC1
 
UiPath Studio Web workshop series - Day 4
UiPath Studio Web workshop series - Day 4UiPath Studio Web workshop series - Day 4
UiPath Studio Web workshop series - Day 4DianaGray10
 
Machine Learning - Dataset Preparation
Machine Learning - Dataset PreparationMachine Learning - Dataset Preparation
Machine Learning - Dataset PreparationAndrew Ferlitsch
 
DSJ_Unit I & II.pdf
DSJ_Unit I & II.pdfDSJ_Unit I & II.pdf
DSJ_Unit I & II.pdfArumugam90
 
Week-3 – System RSupplemental material1Recap •.docx
Week-3 – System RSupplemental material1Recap •.docxWeek-3 – System RSupplemental material1Recap •.docx
Week-3 – System RSupplemental material1Recap •.docxhelzerpatrina
 
Sv data types and sv interface usage in uvm
Sv data types and sv interface usage in uvmSv data types and sv interface usage in uvm
Sv data types and sv interface usage in uvmHARINATH REDDY
 
DATA STRUCTURES unit 1.pptx
DATA STRUCTURES unit 1.pptxDATA STRUCTURES unit 1.pptx
DATA STRUCTURES unit 1.pptxShivamKrPathak
 
Slides on introduction to R by ArinBasu MD
Slides on introduction to R by ArinBasu MDSlides on introduction to R by ArinBasu MD
Slides on introduction to R by ArinBasu MDSonaCharles2
 
Functional Programming in Swift
Functional Programming in SwiftFunctional Programming in Swift
Functional Programming in SwiftSaugat Gautam
 
Data structure and algorithm.
Data structure and algorithm. Data structure and algorithm.
Data structure and algorithm. Abdul salam
 

Similar to Intro to plyr for Davis R Users' Group, by Steve Culman (20)

358 33 powerpoint-slides_4-introduction-data-structures_chapter-4
358 33 powerpoint-slides_4-introduction-data-structures_chapter-4358 33 powerpoint-slides_4-introduction-data-structures_chapter-4
358 33 powerpoint-slides_4-introduction-data-structures_chapter-4
 
UNIT 1.pptx
UNIT 1.pptxUNIT 1.pptx
UNIT 1.pptx
 
Data Structures in C
Data Structures in CData Structures in C
Data Structures in C
 
Functional Programming.pptx
Functional Programming.pptxFunctional Programming.pptx
Functional Programming.pptx
 
U nit i data structure-converted
U nit   i data structure-convertedU nit   i data structure-converted
U nit i data structure-converted
 
Mathematical Modeling With Maple
Mathematical Modeling With MapleMathematical Modeling With Maple
Mathematical Modeling With Maple
 
Hadoop map reduce concepts
Hadoop map reduce conceptsHadoop map reduce concepts
Hadoop map reduce concepts
 
Data Structures 7
Data Structures 7Data Structures 7
Data Structures 7
 
Data Structure & aaplications_Module-1.pptx
Data Structure & aaplications_Module-1.pptxData Structure & aaplications_Module-1.pptx
Data Structure & aaplications_Module-1.pptx
 
UiPath Studio Web workshop series - Day 4
UiPath Studio Web workshop series - Day 4UiPath Studio Web workshop series - Day 4
UiPath Studio Web workshop series - Day 4
 
Machine Learning - Dataset Preparation
Machine Learning - Dataset PreparationMachine Learning - Dataset Preparation
Machine Learning - Dataset Preparation
 
DSJ_Unit I & II.pdf
DSJ_Unit I & II.pdfDSJ_Unit I & II.pdf
DSJ_Unit I & II.pdf
 
Week-3 – System RSupplemental material1Recap •.docx
Week-3 – System RSupplemental material1Recap •.docxWeek-3 – System RSupplemental material1Recap •.docx
Week-3 – System RSupplemental material1Recap •.docx
 
Sv data types and sv interface usage in uvm
Sv data types and sv interface usage in uvmSv data types and sv interface usage in uvm
Sv data types and sv interface usage in uvm
 
DATA STRUCTURES unit 1.pptx
DATA STRUCTURES unit 1.pptxDATA STRUCTURES unit 1.pptx
DATA STRUCTURES unit 1.pptx
 
17641.ppt
17641.ppt17641.ppt
17641.ppt
 
Slides on introduction to R by ArinBasu MD
Slides on introduction to R by ArinBasu MDSlides on introduction to R by ArinBasu MD
Slides on introduction to R by ArinBasu MD
 
17641.ppt
17641.ppt17641.ppt
17641.ppt
 
Functional Programming in Swift
Functional Programming in SwiftFunctional Programming in Swift
Functional Programming in Swift
 
Data structure and algorithm.
Data structure and algorithm. Data structure and algorithm.
Data structure and algorithm.
 

More from Noam Ross

An introduction to structural equation models in R using the Lavaan package
An introduction to structural equation models in R using the Lavaan packageAn introduction to structural equation models in R using the Lavaan package
An introduction to structural equation models in R using the Lavaan packageNoam Ross
 
Spatial Analysis with R - the Good, the Bad, and the Pretty
Spatial Analysis with R - the Good, the Bad, and the PrettySpatial Analysis with R - the Good, the Bad, and the Pretty
Spatial Analysis with R - the Good, the Bad, and the PrettyNoam Ross
 
R and the forest vegetation simulator
R and the forest vegetation simulatorR and the forest vegetation simulator
R and the forest vegetation simulatorNoam Ross
 
Andersen et al. 2004: Stoichiometry and Dynamics
Andersen et al. 2004: Stoichiometry and DynamicsAndersen et al. 2004: Stoichiometry and Dynamics
Andersen et al. 2004: Stoichiometry and DynamicsNoam Ross
 
General Additive Models in R
General Additive Models in RGeneral Additive Models in R
General Additive Models in RNoam Ross
 
Agren 2012 - by Brian Smithers
Agren 2012 - by Brian SmithersAgren 2012 - by Brian Smithers
Agren 2012 - by Brian SmithersNoam Ross
 
Stoichiometry of the Microbial Loop: J. Matthew Haggerty
Stoichiometry of the Microbial Loop: J. Matthew HaggertyStoichiometry of the Microbial Loop: J. Matthew Haggerty
Stoichiometry of the Microbial Loop: J. Matthew HaggertyNoam Ross
 
Ecological Stoichiometry: The Consumer Connection: Matt Whalen
Ecological Stoichiometry: The Consumer Connection: Matt WhalenEcological Stoichiometry: The Consumer Connection: Matt Whalen
Ecological Stoichiometry: The Consumer Connection: Matt WhalenNoam Ross
 
Stoichiometry of the Microbial Loop: J. Matthew Haggerty
Stoichiometry of the Microbial Loop: J. Matthew HaggertyStoichiometry of the Microbial Loop: J. Matthew Haggerty
Stoichiometry of the Microbial Loop: J. Matthew HaggertyNoam Ross
 
Marklein CNP stoichiometry
Marklein CNP stoichiometryMarklein CNP stoichiometry
Marklein CNP stoichiometryNoam Ross
 
Modifying River-Floodplain Systems: A Historical and Ecological Perspective
Modifying River-Floodplain Systems: A Historical and Ecological PerspectiveModifying River-Floodplain Systems: A Historical and Ecological Perspective
Modifying River-Floodplain Systems: A Historical and Ecological PerspectiveNoam Ross
 
Emerging Forest Disease
Emerging Forest DiseaseEmerging Forest Disease
Emerging Forest DiseaseNoam Ross
 
Baskett Lab Uncertainty lab meeting
Baskett Lab Uncertainty lab meetingBaskett Lab Uncertainty lab meeting
Baskett Lab Uncertainty lab meetingNoam Ross
 

More from Noam Ross (13)

An introduction to structural equation models in R using the Lavaan package
An introduction to structural equation models in R using the Lavaan packageAn introduction to structural equation models in R using the Lavaan package
An introduction to structural equation models in R using the Lavaan package
 
Spatial Analysis with R - the Good, the Bad, and the Pretty
Spatial Analysis with R - the Good, the Bad, and the PrettySpatial Analysis with R - the Good, the Bad, and the Pretty
Spatial Analysis with R - the Good, the Bad, and the Pretty
 
R and the forest vegetation simulator
R and the forest vegetation simulatorR and the forest vegetation simulator
R and the forest vegetation simulator
 
Andersen et al. 2004: Stoichiometry and Dynamics
Andersen et al. 2004: Stoichiometry and DynamicsAndersen et al. 2004: Stoichiometry and Dynamics
Andersen et al. 2004: Stoichiometry and Dynamics
 
General Additive Models in R
General Additive Models in RGeneral Additive Models in R
General Additive Models in R
 
Agren 2012 - by Brian Smithers
Agren 2012 - by Brian SmithersAgren 2012 - by Brian Smithers
Agren 2012 - by Brian Smithers
 
Stoichiometry of the Microbial Loop: J. Matthew Haggerty
Stoichiometry of the Microbial Loop: J. Matthew HaggertyStoichiometry of the Microbial Loop: J. Matthew Haggerty
Stoichiometry of the Microbial Loop: J. Matthew Haggerty
 
Ecological Stoichiometry: The Consumer Connection: Matt Whalen
Ecological Stoichiometry: The Consumer Connection: Matt WhalenEcological Stoichiometry: The Consumer Connection: Matt Whalen
Ecological Stoichiometry: The Consumer Connection: Matt Whalen
 
Stoichiometry of the Microbial Loop: J. Matthew Haggerty
Stoichiometry of the Microbial Loop: J. Matthew HaggertyStoichiometry of the Microbial Loop: J. Matthew Haggerty
Stoichiometry of the Microbial Loop: J. Matthew Haggerty
 
Marklein CNP stoichiometry
Marklein CNP stoichiometryMarklein CNP stoichiometry
Marklein CNP stoichiometry
 
Modifying River-Floodplain Systems: A Historical and Ecological Perspective
Modifying River-Floodplain Systems: A Historical and Ecological PerspectiveModifying River-Floodplain Systems: A Historical and Ecological Perspective
Modifying River-Floodplain Systems: A Historical and Ecological Perspective
 
Emerging Forest Disease
Emerging Forest DiseaseEmerging Forest Disease
Emerging Forest Disease
 
Baskett Lab Uncertainty lab meeting
Baskett Lab Uncertainty lab meetingBaskett Lab Uncertainty lab meeting
Baskett Lab Uncertainty lab meeting
 

Recently uploaded

This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxcallscotland1987
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdfssuserdda66b
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 

Recently uploaded (20)

This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 

Intro to plyr for Davis R Users' Group, by Steve Culman

  • 1. Split-Apply-Combine Strategy with the Package plyr Hadley Wickham. The split-apply-combine strategy for data analysis. Journal of Statistical Software, 40(1):1–29, 2011. URL http://www.jstatsoft.org/v40/i01/. http://plyr.had.co.nz/
  • 2. Common action in statistical analyses: • Split up a dataset into pieces • Apply a function to these pieces • Combine output and examine the results Examples: • Calculate the mean of response by treatment • Run ANOVA on numerous response variables • Calculate total precipitation from weather data by month or year
  • 3. plyr offers: • a streamlined, simplified, and unified framework and alterative to the R ‘apply’ base functions (apply, sapply, tapply, lapply, mapply, etc.) • a streamlined and simplified approach to writing for loops When not to use plyr: • each iteration requires overlapping data (e.g., running mean) • each iteration depends on the previous iteration (e.g., dynamic simulation)
  • 4. The package plyr uses a similar command **ply • where the 1st ‘*’ designates the input type • 2nd ‘*’ designates the output type. The choices for the ‘*’ are either, ‘a’, ‘d’, ‘l’, or ’_’ • a = array • d = data frame • l = list • _ means the output is discarded • Examples: – ddply = input is a dataframe, output is a data frame – alply = input is an array, output is a list
  • 5. • Full function: ddply(.data, .variables, .fun, ..., ) • .data = R object that will be split up, processed and recombined • .variables (.margins for arrays) = describes how to split up the input into pieces • .fun, = the processing function, and is applied to each piece in turn. • All further arguments are passed on to the processing function. • If you omit .fun the individual pieces will not be modified, but the entire data structure will be converted from one type to another.
  • 6. The package plyr uses a similar command style: **ply • where the 1st ‘*’ designates the input type • 2nd ‘*’ designates the output type. The choices for the ‘*’ are either, ‘a’, ‘d’, ‘l’, or ’_’ • a = array • d = data frame • l = list • _ = the output is discarded • Examples: – ddply = input is a data frame, output is a data frame – alply = input is an array, output is a list