R Packages Davor Cubranic SCARL, Dept. of Statistics.

Slides:



Advertisements
Similar presentations
JQuery MessageBoard. Lets use jQuery and AJAX in combination with a database to update and retrieve information without refreshing the page. Here we will.
Advertisements

Focus on Your Content, Not on Ingesting Your Content Terry Brady Applications Programmer Analyst Georgetown University Library
Introduction to R Brody Sandel. Topics Approaching your analysis Basic structure of R Basic programming Plotting Spatial data.
CC SQL Utilities.
Introduction to Tables of Contents (TOCs) j then press F5 or click Slide Show > From Beginning to start the course. In the message bar, click Enable Editing,
R Packages Davor Cubranic SCARL, Dept. of Statistics.
Microsoft TM SharePoint Content Management SystemTutorial By Mazen Abdallah Student Assistant at CNS 2010.
MatLab API in C++ Christopher Dabney. Purpose MatLab … MatLab … is an interpreted scripting language is an interpreted scripting language conversion to.
Refresh- Caitlin Collins, Thibaut Jombart MRC Centre for Outbreak Analysis and Modelling Imperial College London Genetic data analysis using
Endnote Tutorial The Version pictured is version 9.0 May 8, 2007.
 Statistics package  Graphics package  Programming language  Can be used to share/reproduce analyses  Many new packages being created - can be downloaded.
© 2005 Wellesley Information Services. All rights reserved. Error Handling in LotusScript Agents Chuck Connell CHC-3 Consulting.
How to Use the R Programming Language for Statistical Analyses Part I: An Introduction to R Jennifer Urbano Blackford, Ph.D. Department of Psychiatry Kennedy.
Introduction to JavaScript. Aim To enable you to write you first JavaScript.
XP New Perspectives on Microsoft Access 2002 Tutorial 71 Microsoft Access 2002 Tutorial 7 – Integrating Access With the Web and With Other Programs.
Automation Repository - QTP Tutorials Made Easy The Zero th Step TEST AUTOMATION AND QTP.
Microsoft Office Word 2013 Expert Microsoft Office Word 2013 Expert Courseware # 3251 Lesson 4: Working with Forms.
Adobe Acrobat. Overview Basic Skills – Updating – Making – Updating – Sending Advanced – Form creation – Data Exportation Help Resources.
1 Introduction to Tool chains. 2 Tool chain for the Sitara Family (but it is true for other ARM based devices as well) A tool chain is a collection of.
TrendReader Standard 2 This generation of TrendReader Standard software utilizes the more familiar Windows format (“tree”) views of functions and file.
Inti Online Login Page (Lecturer/Student/Administrator View)
Ext Environment Copyright © 2005 Liferay, LLC All Rights Reserved. No material may be reproduced electronically or in print without written permission.
StyleCop Breaking down the barriers to entry Gary Ewan Park Twitter: Blog:
Introduction to R Part 2. Working Directory The working directory is where you are currently saving data in R. What is the current working directory?
DTIAtlasBuilder Adrien Kaiser Neuro Image Research and Analysis Laboratories University of North Carolina at Chapel Hill A tool to create an atlas from.
Ext Environment Copyright © 2005 Liferay, LLC All Rights Reserved. No material may be reproduced electronically or in print without written permission.
3.01 – Understand Business Documents Mail Merge. Administration Congratulations in order! Objective 3.01 Business Documents Test –Test Wednesday –Review.
Mail merge I: Use mail merge for mass mailings Perform a complete mail merge Now you’ll walk through the process of performing a mail merge by using the.
Working with Data in Windows HRP223 – 2009 Sept 28 th, 2009 Copyright © Leland Stanford Junior University. All rights reserved. Warning: This.
Scalable Game Development William Roberts Senior Game Engineer
Lecture Set 1 Part C: Understanding Visual Studio and.NET – Applications, Solutions, Projects (no longer used – embedded in Lecture Set 2A)
R BRO SOLUTIONS INC. ©2006 RBRO Solutions Inc., All Rights Reserved Systems Design Consultants Document Migration into WorkSite.
Piotr Wolski Introduction to R. Topics What is R? Sample session How to install R? Minimum you have to know to work in R Data objects in R and how to.
Renesas Technology America Inc. 1 SKP8CMINI Tutorial 2 Creating A New Project Using HEW.
Lecture 6: Computer Languages. Programming Environments (IDE) COS120 Software Development Using C++ AUBG, COS dept.
Lecture Set 2 Part A: Creating an Application with Visual Studio – Solutions, Projects, Files.
An Introduction to Designing and Executing Workflows with Taverna Aleksandra Pawlik materials by: Katy Wolstencroft University of Manchester.
Documentation NCRR Documentation for BioPSE/SCIRun and map3d All this great software and you want documentation too!?
What is a port The Ports Collection is essentially a set of Makefiles, patches, and description files placed in /usr/ports. The port includes instructions.
Renesas Technology America Inc. 1 M16C Seminars Lab 3 Creating Projects Using HEW4 14 March 2005 M16C Seminars Lab 3 Creating Projects Using HEW4 Last.
Introduction to R Introductions What is R? RStudio Layout Summary Statistics Your First R Graph 17 September 2014 Sherubtse Training.
CharMeck.org Contributer Training SharePoint 2013 Orientation and Basic Training.
C++ LANGUAGE TUTORIAL LESSON 1 –WRITING YOUR FIRST PROGRAM.
Intermediate 2 Computing Unit 2 - Software Development.
12 CVS Mauro Jaskelioff (originally by Gail Hopkins)
Renesas Technology America Inc. 1 SKP8CMINI Tutorial 2 Creating A New Project Using HEW.
More Unix Naomi Altman. Directories Directory = folder mkdir - makes a new directory rmdir - removes an empty directory cd mydirectory - moves you into.
Introductory Data Analysis F73DA2. Contact Times (Spring Term 2008) Monday 4: : Lecture in LT3 Tuesday 2: : Lecture in LT3 Wednesday
1 EPIB 698C Lecture 1 Instructor: Raul Cruz-Cano
Chris Knight Beginners’ workshop.
OCR A Level F453: The function and purpose of translators Translators a. describe the need for, and use of, translators to convert source code.
Troubleshooting Dashhawk Issues. Here's what you have to do to have the DashHawk run properly Go to the ACTUAL PROGRAM file (not the short cut)
1 Adding a Model. We have created an MVC web app project Added a controller class. Added a view class. Next we will add some classes for managing movies.
Classroom Wiki Tutorial EDIC 763 Instructional Design Fall 2011 Aysha Bajabaa Dr. Gary Whitt 1 NextBack.
Perform a complete mail merge Lesson 14 By the end of this lesson you will be able to complete the following: Use the Mail Merge Wizard to perform a basic.
Welcome to the Basic Microsoft Word Guide. Before you start this Guide, you will need to complete “Basic Computer”; “Basic Windows” and know how to type.
Finding Magazine & Newspaper Articles in a Library Database
Development Environment
Finding Scholarly Articles in a Library Database
Microsoft Word 2010 Lesson 1 Revised February 9, 2011
Getting Started with R.
Installing R and R Studio
R Programming.
Working with Data in Windows
Lab 1 Introductions to R Sean Potter.
JavaTeaching and Importing a github repository
Macrosystems EDDIE: Getting Started + Troubleshooting Tips
Manual Water Ski Directory
Tutorial 7 – Integrating Access With the Web and With Other Programs
Tutorial 10: Programming with javascript
Presentation transcript:

R Packages Davor Cubranic SCARL, Dept. of Statistics

Warmup questions Who here uses packages? Which ones? How do you know you’re using a package? – Had to install it – Had to load it What happens when you load it? – Functions – Data – Help pages

So package is a bundle of “stuff” But, (next slide) It’s a structured bundle of…

What is a package? Structured, standardized unit of: – R code – documentation – data – external code

Why use packages (talking points) Installation & administration is easy – Finding, installing, compiling, updating… Validation – Package checks Distribution mechanisms – CRAN, Bioconductor, Github Documentation – Bundle examples, demos, tutorials Organization – Especially useful for the programmers: – Self-contained (names) – Declare and enforce dependencies on other packages

Why use packages Installation & administration Validation Distribution Documentation Organization

Knowing how packages work and how to use them effectively will make you more effective R analyst, even if you don’t develop new packages But you should consider developing packages even if you don’t write the next ggplot Packages for your own stuff: -Analyses you frequently repeat and/or share with others -Publication: create a package containing the publication as a vignette, and bundle the code and data with it

Handling packages Load with library( name ) Package-level help: –library(help= name ) Unload with detach(package: name ) – You shouldn’t have to do this

Handling packages with RStudio See the packages tab in Rstudio Checkmark to load Some are already loaded!! Click on the name for help

What happens when you load a package? When you start R you have an empty workspace But there is also all this other “basic” R stuff (matrix, plot) So it’s more like we have two boxes, your workspace and “core” R Actually, it’s more like a whole bunch of boxes: see search()

So what happens when you load? New package gets inserted near the front of the list It can pull additional packages (dependencies) But notice that each package is its own bundle (box) We’ll talk how you create these bundles next

Structure What makes package a package is that it follows a prescribed structure of files and directories If you tell R to treat this as a package, it will You can create it by hand, but we’ll use a shortcut: package.skeleton()

package.skeleton() Convenient for turning a set of existing functions and scripts into a package Let’s do it with the anova.mlm code that we wrote earlier

New project: – source(‘anova.mlm.R’) package.skeleton(“anovaMlm”, ls())

DESCRIPTION The only required part of a package Name, author, license, etc.

R/ Directory for R code package.skeleton creates one file per function This is not a rule, you can put as many functions into a single file

man/ Help files

NAMESPACE Defines which objects are visible to the user and other functions Public vs. private to the package The default is to make everything visible that starts with a letter

Command-line tools Check Install Build

INSTALL Let’s install our package R CMD INSTALL anova.mlm Delete the “man” directory – (it’s optional and we’ll recreate it later) Redo INSTALL Restart R studio library(“anova.mlm”)

check Really important!!! Finds common errors, non-standard parts CRAN requires no ERRORS or WARNINGS

Optional contents man/: documentation data/: datasets demo/: R code for demo purposes inst/: other files to include in the package (PDFs, vignettes) tests/: package test files src/: C, C++, or Fortran source code NEWS: history of changes to the package LICENSE or LICENCE: package license

DESCRIPTION Depends: – packages used by this one – and loaded as part of its loading – i.e., visible to the user Imports: – packages used by this one – but not loaded – i.e, not visible to the user Suggests: – used in examples or vignettes – non-essential functionality

NAMESPACE exportPattern(“^[[:alpha:]]”) export(anova.mlm, est.beta) S3method(print, anova.mlm) S3method(plot, anova.mlm) import(MASS) importFrom(MASS, lda)

Documentation Let’s re-generate the documentation files promptPackage(“anova.mlm”) prompt(anova.mlm)

anova.mlm.Rd Description: Compute a (generalized) analysis of variance table for one or more multivariate linear models. Arguments: – object: an object of class '"mlm”’ –...: further objects of class '"mlm"’. – force.int: Force intercept Value: An object of class “anova” inheriting from class “matrix”

Help files for methods \usage{anova.mlm(…)} For S3 methods: – \usage{\method{print}{anova.mlm}(….)}

Vignettes.rnw extension Written in Sweave – similar to knitr Latex + R code Produces a PDF available in the installed package vignette() vignette(‘Sweave’)

Help on writing packages Lots of tutorials on the Web – many of them are not necessarily correct – NAMESPACES, Imports, etc. Authoritative guide: Writing R Extensions R-devel mailing list