Hands on S4 Classes. Yohan Chalabi. R/Rmetrics Workshop Meielisalp June ITP ETH, Zurich Rmetrics Association, Zurich Finance Online, Zurich

Size: px
Start display at page:

Download "Hands on S4 Classes. Yohan Chalabi. R/Rmetrics Workshop Meielisalp June 2009. ITP ETH, Zurich Rmetrics Association, Zurich Finance Online, Zurich"

Transcription

1 Hands on S4 Classes Yohan Chalabi ITP ETH, Zurich Rmetrics Association, Zurich Finance Online, Zurich R/Rmetrics Workshop Meielisalp June 2009

2 Outline 1 Introduction 2 S3 Classes/Methods 3 S4 Classes/Methods

3 Outline 1 Introduction 2 S3 Classes/Methods 3 S4 Classes/Methods

4 S3/S4 History The appendix in Software for Data Analysis by Chambers [1] is of great interest to learn more about the history of the S language. First discussion at Bell labs in May 1976 for a new system to interface a large Fortran library. By the end of 1976 Rick Becker and John Chambers with the help of co-workers have a first implementation of S running locally on Honeywell OS. This new language is later ported to UNIX systems and becomes the S version 2. About ten years after the first meeting, a new version with concepts inspired from UNIX system is developed with focus on functional programming and with object self-description. This is the S version 3. Around 1992 is introduced the concept of classes and methods as known today by S4 classes.

5 Goal of the Tutorial The goal of this tutorial is to introduce concepts and methods of S4 classes in R. We will start with a brief overview of S3 classes and introduce S4 classes in comparison with their S3 counterparts. As an example we will implement a class which could represent a time series. This object will hold a data part (matrix), timestamps (timedate) and additional information in the form of data.frame s that we will call flag s. > library(timedate) > time <- as.character(timesequence(length.out=4)) > data <- matrix(round(rnorm(8), 3), ncol = 2) > colnames(data) <- c("col1", "col2") > flag <- data.frame(flag = sample(c("m", "F"), 4, replace = TRUE))

6 Outline 1 Introduction 2 S3 Classes/Methods 3 S4 Classes/Methods

7 S3 classes An S3 class is defined by the special attribute class, a character string vector. In our case the, Bull class. 1 > bull <- data > attr(bull, "class") <- "Bull" > bull col1 col2 [1,] [2,] [3,] [4,] attr(,"class") [1] "Bull" > bull <- data > class(bull) <- "Bull" > bull col1 col2 [1,] [2,] [3,] [4,] attr(,"class") [1] "Bull" Note the class() function to define a class. 1 imagine bulls and cows mooing in the field next to the conference room

8 S3 classes Now we add new attributes for the timestamps and the additional information flag. > attr(bull, "time") <- time > attr(bull, "flag") <- flag > bull col1 col2 [1,] [2,] [3,] [4,] attr(,"class") [1] "Bull" attr(,"time") [1] " :04:46" " :04:46" [3] " :04:46" " :04:46" attr(,"flag") flag 1 F 2 F 3 M 4 F

9 S3 methods In the world of S3 classes, methods of generic functions can be defined with a new functions named according to the scheme <generic name>.<class>. Here a generic function is a function which dispatches the S3 method with UseMethod(). There are some functions which are S3 generics. For example print(), plot(),... Note S3 methods only dispatch on the type of the first argument. If no method is found, the default methods is used (<generic name>.default). > print function (x,...) UseMethod("print") <environment: namespace:base> > head(methods(print)) #-> too many methods [1] "print.acf" "print.anova" "print.aov" [4] "print.aovlist" "print.ar" "print.arima"

10 S3 methods Let s define a print() method for our class "Bull" > print.bull <- function(x,...) { y <- matrix(c(x), ncol = ncol(x)) dimnames(y) <- list(as.character(attr(x, "time")), colnames(x)) cat("meielisalp\n") print(y) invisible(x) } > bull Meielisalp col1 col :04: :04: :04: :04:

11 S3 generic Let s define a new generic function with its default method > dinner <- function(x,...) UseMethod("dinner") > dinner.default <- function(x,...) cat("a Swiss Fondue\n") This will give with our class > dinner(bull) A Swiss Fondue and with a defined method for the class Bull. > dinner.bull <- function(x,...) cat("hay!!\n") > dinner(bull) Hay!!

12 S3 group generic There are group generic methods for a specified group of functions Math, Ops, Summary and Complex. > methods("math") [1] Math.data.frame Math.Date Math.difftime [4] Math.factor Math.POSIXt > getgroupmembers("math") [1] "abs" "sign" "sqrt" "ceiling" "floor" [6] "trunc" "cummax" "cummin" "cumprod" "cumsum" [11] "exp" "expm1" "log" "log10" "log2" [16] "log1p" "cos" "cosh" "sin" "sinh" [21] "tan" "tanh" "acos" "acosh" "asin" [26] "asinh" "atan" "atanh" "gamma" "lgamma" [31] "digamma" "trigamma"

13 S3 inheritance S3 classes indirectly inherits the methods of its data part because the S3 objects is just an R object with attributes. More than one string can be added in the class attributes if one wants to share common properties between different classes. A good example are the classes : POSIXct, POSIXlt and POSIXt. > class(sys.time()) [1] "POSIXt" "POSIXct" > class(as.posixlt(sys.time())) [1] "POSIXt" "POSIXlt"

14 S3 Classes - Key Functions class() methods() UseMethod() NextMethod() Defines the class attribute Lists S3 methods for a class Generic function mechanism Invokes the next method

15 Drawbacks of S3 Classes It does not check the consistency of the class. It has no control on inheritance. S3 methods can only dispatch on the first argument. By the time S4 classes were introduced there were too many software implemented in S3 style. We have to live with both worlds.

16 Outline 1 Introduction 2 S3 Classes/Methods 3 S4 Classes/Methods

17 S4 Classes A new class can be created with the function setclass(). It defines metadata with information about the new classes. setclass() requires the type of all components of the class. It ensure the consistency of the class. > setclass("cow", representation(data = "matrix", time = "character", flag = "data.frame")) [1] "Cow" > # class metadata >. C Cow Class "Cow" [in ".GlobalEnv"] Slots: Name: data time flag Class: matrix character data.frame

18 S4 Classes New instance of classes can be created with the function new(). > cow <- new("cow", data = data, time = time, flag = flag) > cow An object of class "Cow" Slot "data": col1 col2 [1,] [2,] [3,] [4,] Slot "time": [1] " :04:46" " :04:46" [3] " :04:46" " :04:46" Slot "flag": flag 1 F 2 F 3 M 4 F

19 S4 Classes The structure of the class can be inspected with the str() function. > str(cow) Formal class 'Cow' [package ".GlobalEnv"] with 3 slots..@ data: num [1:4, 1:2] attr(*, "dimnames")=list of $ : NULL......$ : chr [1:2] "col1" "col2"..@ time: chr [1:4] " :04:46" " :04:46" " @ flag:'data.frame': 4 obs. of 1 variable:....$ flag: Factor w/ 2 levels "F","M":

20 S4 slots A class representation is organized in slots which can be accessed by the : > cow@data col1 col2 [1,] [2,] [3,] [4,] > cow@data <- data

21 restriction on the type of object in slots When a slot is assigned, the object is automatically checked for a valid slot type. For instance, if we try to assign a character vector to slot which is of type data.frame, we get an error. > cow@flag <- "bad" Error in checkslotassignment(object, name, value) : assignment of an object of class "character" is not valid for slot "flag" in an object of class "Cow"; is(value, "data.frame") is not TRUE

22 Inheritance In our definition of the Cow class, there is no inheritance method. Trying to use a generic function like + will throw an error. > cow + 1 Error in cow + 1 : non-numeric argument to binary operator

23 Inheritance But we could have defined the class with the contains argument in setclass(). Let s redefine our class such that it inherits from the class matrix. > setclass("cow", representation(time = "character", flag = "data.frame"), contains = "matrix") [1] "Cow" > cow <- new("cow", data, time = time, flag = flag) > cow + 1 An object of class "Cow" col1 col2 [1,] [2,] [3,] [4,] Slot "time": [1] " :04:46" " :04:46" [3] " :04:46" " :04:46" Slot "flag": flag

24 Inheritance Note a class inheriting from another class must have all slots from its superclass, and may define additional slots. S4 classes cannot inherits from S3 classes unless they have been redefined with the setoldclass() function. > getclass("cow") Class "Cow" [in ".GlobalEnv"] Slots: Name:.Data time flag Class: matrix character data.frame Extends: Class "matrix", from data part Class "array", by class "matrix", distance 2 Class "structure", by class "matrix", distance 3 Class "vector", by class "matrix", distance 4, with explicit coerce

25 S4 Validity Checks We can also define validity checks with setvalidity(). > validitycow <- function(object) { if (nrow(object@flag)!= nrow(object)) return("length of '@flag' not equal to '@.Data' extent") TRUE } > setvalidity("cow", validitycow) Class "Cow" [in ".GlobalEnv"] Slots: Name:.Data time flag Class: matrix character data.frame Extends: Class "matrix", from data part Class "array", by class "matrix", distance 2 Class "structure", by class "matrix", distance 3 Class "vector", by class "matrix", distance 4, with explicit coerce

26 S4 Validity Checks Now we define our own initialize() method to ensure that objects created with new() are valid. > setmethod("initialize", "Cow", function(.object,...) { value <- callnextmethod() validobject(value) value }) [1] "initialize" > new("cow", data, flag = data.frame(flag[1:3,])) Error in validobject(value) : invalid class "Cow" object: length of '@flag' not equal to '@.Data' extent

27 S4 Methods As you have just seen in the previous chunk, S4 methods are defined with setmethod(). Let s write a show() method for our class. > setmethod("show", "Cow", function(object) { value <- getdatapart(object) rownames(value) <- as.character(slot(object, "time")) flag <- as.matrix(slot(object, "flag")) colnames(flag) <- paste(colnames(flag), "*", sep ="") cat("meielisalp\n") print(cbind(value, flag), right = TRUE, quote = FALSE) }) [1] "show" > cow Meielisalp col1 col2 flag* :04: F :04: F :04: M :04: F

28 S4 Generic S4 generics are defined with setgeneric() and standardgeneric(). > setgeneric("cowseries", function(x, time, flag,...) standardgeneric("cowseries")) [1] "cowseries" Unlike S3 methods, the S4 setmethod() can turn any existing function to a generic, except primitive functions. Dispatch on primitive functions is implemented in C level and most of the primitive functions in R have it. One can also define group generics with setgroupgeneric() or use the predefined groups : Arith, Compare, Ops, Logic, Math, Math2, Summary, Complex.

29 Multiple dispatch S3 methods are only dispatch on the first argument. You often need many if... else... in your code when you are dealing with different argument types. > graphics:::plot.factor function (x, y, legend.text = NULL,...) { if (missing(y) is.factor(y)) { dargs <- list(...) axisnames <- if (!is.null(dargs$axes)) dargs$axes else if (!is.null(dargs$xaxt)) dargs$xaxt!= "n" else TRUE } if (missing(y)) { barplot(table(x), axisnames = axisnames,...) } else if (is.factor(y)) { if (is.null(legend.text)) spineplot(x, y,...) else { args <- c(list(x = x, y = y), list(...)) args$yaxlabels <- legend.text

30 Multiple dispatch With S4 methods you can define the type of all argument and also the special types ANY and missing. > setmethod("cowseries", signature("matrix", "character", "data.frame"), function(x, time, flag,...) new("cow", x, time = time, flag = flag)) [1] "cowseries" > cowseries(data, time, flag) Meielisalp col1 col2 flag* :04: F :04: F :04: M :04: F

31 Multiple dispatch > setmethod("cowseries", signature("matrix", "POSIXct", "character"), function(x, time, flag,...) { time <- as(time, "character") flag <- as.data.frame(flag) callgeneric(x, time, flag,...) }) [1] "cowseries" > timect <- seq(from = Sys.time(), to = (Sys.time() + 4*3600), length.out = 4) > flagstr <- as.character(flag[[1]]) > cowseries(data, timect, flagstr) Meielisalp col1 col2 flag* :04: F :24: F :44: M :04: F

32 Object Conversion as() can be used to convert an object to another class > as(cow, "matrix") col1 col2 [1,] [2,] [3,] [4,] and one can defined conversion methods with setas(). Let s define a more appropriate as() method for our class : > setas("cow", "matrix", function(from) { value <- getdatapart(from) rownames(value) <- as.character(slot(from, "time")) value }) [1] "coerce<-" > as(cow, "matrix") col1 col :04: :04: :04: :04:

33 What is an S4 class in R? S4 slots are actually attributes and, in low level, S4 objects has a special S4 bit > attrscow <- attributes(cow) > madcow <- data > attributes(madcow) <- attrscow > ass4(madcow) Meielisalp col1 col2 flag* :04: F :04: F :04: M :04: F BUT! You have to promise that you will never use such a trick!

34 What is an S4 class in R? S4 slots are actually attributes and, in low level, S4 objects has a special S4 bit > attrscow <- attributes(cow) > madcow <- data > attributes(madcow) <- attrscow > ass4(madcow) Meielisalp col1 col2 flag* :04: F :04: F :04: M :04: F BUT! You have to promise that you will never use such a trick!

35 S4 Classes - Key functions setclass() new() setgeneric() setmethods() as() / / slot() setvalidity() / validobject() getclass() / showmethods() / getmethod() define classes create objects define generics define methods convert objects access slots check object validity access registry

36 References I J.M. Chambers Software for data analysis: programming with R Springer, R Development Core Team?Clasees and?methods manual pages 2009.

37 > tolatex(sessioninfo()) R version Under development (unstable) ( r48824), i686-pc-linux-gnu Locale: LC_CTYPE=en_US.UTF-8, LC_NUMERI... Base packages: base, datasets, graphics, grdevices, methods, stats, utils Other packages: timedate Loaded via a namespace (and not attached): tools

38 Hands on S4 Classes Yohan Chalabi ITP ETH, Zurich Rmetrics Association, Zurich Finance Online, Zurich R/Rmetrics Workshop Meielisalp June 2009

Acknowledgements. S4 Classes and Methods. Overview. Introduction. S4 has been designed and written by. John Chambers. These slides contain material by

Acknowledgements. S4 Classes and Methods. Overview. Introduction. S4 has been designed and written by. John Chambers. These slides contain material by Acknowledgements S4 has been designed and written by John Chambers S4 Classes and Methods Friedrich Leisch These slides contain material by Robert Gentleman R Development Core Group Paul Murrell user!

More information

Object Oriented Programming

Object Oriented Programming Object Oriented Programming Object oriented programming concepts are in many programming languages R has a different model than C++/Java/Python/JavaScript But sall two fundamental concepts in common polymorphism/generic

More information

Adatelemzés II. [SST35]

Adatelemzés II. [SST35] Adatelemzés II. [SST35] Idősorok 0. Lőw András low.andras@gmail.com 2011. október 26. Lőw A (low.andras@gmail.com Adatelemzés II. [SST35] 2011. október 26. 1 / 24 Vázlat 1 Honnan tudja a summary, hogy

More information

Package fimport. February 19, 2015

Package fimport. February 19, 2015 Version 3000.82 Revision 5455 Date 2013-03-15 Package fimport February 19, 2015 Title Rmetrics - Economic and Financial Data Import Author Diethelm Wuertz and many others Depends R (>= 2.13.0), methods,

More information

Package TimeWarp. R topics documented: April 1, 2015

Package TimeWarp. R topics documented: April 1, 2015 Type Package Title Date Calculations and Manipulation Version 1.0.12 Date 2015-03-30 Author Tony Plate, Jeffrey Horner, Lars Hansen Maintainer Tony Plate

More information

S4 Classes in 15 pages, more or less

S4 Classes in 15 pages, more or less S4 Classes in 15 pages, more or less February 12, 2003 Overview The preferred mechanism for object oriented programming in R is described in Chambers (1998). The actual implementation is slightly different

More information

Object systems available in R. Why use classes? Information hiding. Statistics 771. R Object Systems Managing R Projects Creating R Packages

Object systems available in R. Why use classes? Information hiding. Statistics 771. R Object Systems Managing R Projects Creating R Packages Object systems available in R Statistics 771 R Object Systems Managing R Projects Creating R Packages Douglas Bates R has two object systems available, known informally as the S3 and the S4 systems. S3

More information

R Language Definition

R Language Definition R Language Definition Version 3.2.3 (2015-12-10) DRAFT R Core Team This manual is for R, version 3.2.3 (2015-12-10). Copyright c 2000 2015 R Core Team Permission is granted to make and distribute verbatim

More information

Working with Financial Time Series Data in R

Working with Financial Time Series Data in R Working with Financial Time Series Data in R Eric Zivot Department of Economics, University of Washington June 30, 2014 Preliminary and incomplete: Comments welcome Introduction In this tutorial, I provide

More information

Package uptimerobot. October 22, 2015

Package uptimerobot. October 22, 2015 Type Package Version 1.0.0 Title Access the UptimeRobot Ping API Package uptimerobot October 22, 2015 Provide a set of wrappers to call all the endpoints of UptimeRobot API which includes various kind

More information

Package HadoopStreaming

Package HadoopStreaming Package HadoopStreaming February 19, 2015 Type Package Title Utilities for using R scripts in Hadoop streaming Version 0.2 Date 2009-09-28 Author David S. Rosenberg Maintainer

More information

Working with xts and quantmod

Working with xts and quantmod Working with xts and quantmod Leveraging R with xts and quantmod for quantitative trading Jeffrey A. Ryan jeffrey.ryan@insightalgo.com R/Finance Workshop Presented on April 24, R/Finance : Applied Finance

More information

AP Computer Science Java Subset

AP Computer Science Java Subset APPENDIX A AP Computer Science Java Subset The AP Java subset is intended to outline the features of Java that may appear on the AP Computer Science A Exam. The AP Java subset is NOT intended as an overall

More information

Errata and Notes for Software for Data Analysis: Programming with R

Errata and Notes for Software for Data Analysis: Programming with R Errata and Notes for Software for Data Analysis: Programming with R John M. Chambers May 13, 2010 The following are the known errors and significant changes, as of the date above. (Small typos and glitches

More information

Package retrosheet. April 13, 2015

Package retrosheet. April 13, 2015 Type Package Package retrosheet April 13, 2015 Title Import Professional Baseball Data from 'Retrosheet' Version 1.0.2 Date 2015-03-17 Maintainer Richard Scriven A collection of tools

More information

Dataframes. Lecture 8. Nicholas Christian BIOST 2094 Spring 2011

Dataframes. Lecture 8. Nicholas Christian BIOST 2094 Spring 2011 Dataframes Lecture 8 Nicholas Christian BIOST 2094 Spring 2011 Outline 1. Importing and exporting data 2. Tools for preparing and cleaning datasets Sorting Duplicates First entry Merging Reshaping Missing

More information

Package sendmailr. February 20, 2015

Package sendmailr. February 20, 2015 Version 1.2-1 Title send email using R Package sendmailr February 20, 2015 Package contains a simple SMTP client which provides a portable solution for sending email, including attachment, from within

More information

Using Open Source Software to Teach Mathematical Statistics p.1/29

Using Open Source Software to Teach Mathematical Statistics p.1/29 Using Open Source Software to Teach Mathematical Statistics Douglas M. Bates bates@r-project.org University of Wisconsin Madison Using Open Source Software to Teach Mathematical Statistics p.1/29 Outline

More information

Package sjdbc. R topics documented: February 20, 2015

Package sjdbc. R topics documented: February 20, 2015 Package sjdbc February 20, 2015 Version 1.5.0-71 Title JDBC Driver Interface Author TIBCO Software Inc. Maintainer Stephen Kaluzny Provides a database-independent JDBC interface. License

More information

Customising spatial data classes and methods

Customising spatial data classes and methods Customising spatial data classes and methods Edzer Pebesma Feb 2008 Contents 1 Programming with classes and methods 2 1.1 S3-style classes and methods.................... 3 1.2 S4-style classes and methods....................

More information

Object Oriented Software Design

Object Oriented Software Design Object Oriented Software Design Introduction to Java - II Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa September 14, 2011 G. Lipari (Scuola Superiore Sant Anna) Introduction

More information

Schema Classes. Polyhedra Ltd

Schema Classes. Polyhedra Ltd Schema Classes Polyhedra Ltd Copyright notice This document is copyright 1994-2006 by Polyhedra Ltd. All Rights Reserved. This document contains information proprietary to Polyhedra Ltd. It is supplied

More information

Cluster Analysis using R

Cluster Analysis using R Cluster analysis or clustering is the task of assigning a set of objects into groups (called clusters) so that the objects in the same cluster are more similar (in some sense or another) to each other

More information

Lab 13: Logistic Regression

Lab 13: Logistic Regression Lab 13: Logistic Regression Spam Emails Today we will be working with a corpus of emails received by a single gmail account over the first three months of 2012. Just like any other email address this account

More information

R Language Fundamentals

R Language Fundamentals R Language Fundamentals Data Types and Basic Maniuplation Steven Buechler Department of Mathematics 276B Hurley Hall; 1-6233 Fall, 2007 Outline Where did R come from? Overview Atomic Vectors Subsetting

More information

Classes and Objects in Java Constructors. In creating objects of the type Fraction, we have used statements similar to the following:

Classes and Objects in Java Constructors. In creating objects of the type Fraction, we have used statements similar to the following: In creating objects of the type, we have used statements similar to the following: f = new (); The parentheses in the expression () makes it look like a method, yet we never created such a method in our

More information

C++ INTERVIEW QUESTIONS

C++ INTERVIEW QUESTIONS C++ INTERVIEW QUESTIONS http://www.tutorialspoint.com/cplusplus/cpp_interview_questions.htm Copyright tutorialspoint.com Dear readers, these C++ Interview Questions have been designed specially to get

More information

Appendix A Doing Things in R

Appendix A Doing Things in R 271 Appendix A Doing Things in R This appendix is not an exhaustive list of all the things that R can do, but rather a list of some common steps you may want to take gathered in one convenient place, and

More information

Package polynom. R topics documented: June 24, 2015. Version 1.3-8

Package polynom. R topics documented: June 24, 2015. Version 1.3-8 Version 1.3-8 Package polynom June 24, 2015 Title A Collection of Functions to Implement a Class for Univariate Polynomial Manipulations A collection of functions to implement a class for univariate polynomial

More information

Distribute your R code with R package

Distribute your R code with R package Distribute your R code with R package Feng Li feng.li@cufe.edu.cn School of Statistics and Mathematics Central University of Finance and Economics June 2, 2014 Revision: June 2, 2014 Today we are going

More information

Sample CSE8A midterm Multiple Choice (circle one)

Sample CSE8A midterm Multiple Choice (circle one) Sample midterm Multiple Choice (circle one) (2 pts) Evaluate the following Boolean expressions and indicate whether short-circuiting happened during evaluation: Assume variables with the following names

More information

Wave Analytics Data Integration

Wave Analytics Data Integration Wave Analytics Data Integration Salesforce, Spring 16 @salesforcedocs Last updated: April 28, 2016 Copyright 2000 2016 salesforce.com, inc. All rights reserved. Salesforce is a registered trademark of

More information

USING WIRESHARK TO CAPTURE AND ANALYZE NETWORK DATA

USING WIRESHARK TO CAPTURE AND ANALYZE NETWORK DATA USING WIRESHARK TO CAPTURE AND ANALYZE NETWORK DATA CPSC 441 TUTORIAL JANUARY 30, 2012 TA: RUITING ZHOU The content of these slides are taken from CPSC 526 TUTORIAL by Nashd Safa (Extended and partially

More information

Introduction to Java

Introduction to Java Introduction to Java The HelloWorld program Primitive data types Assignment and arithmetic operations User input Conditional statements Looping Arrays CSA0011 Matthew Xuereb 2008 1 Java Overview A high

More information

Object-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007

Object-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007 Object-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007 The Java Type System By now, you have seen a fair amount of Java. Time to study in more depth the foundations of the language,

More information

Reading and writing files

Reading and writing files Reading and writing files Importing data in R Data contained in external text files can be imported in R using one of the following functions: scan() read.table() read.csv() read.csv2() read.delim() read.delim2()

More information

Assignment 3 Version 2.0 Reactive NoSQL Due April 13

Assignment 3 Version 2.0 Reactive NoSQL Due April 13 CS 635 Advanced OO Design and Programming Spring Semester, 2016 Assignment 3 2016, All Rights Reserved, SDSU & Roger Whitney San Diego State University -- This page last updated 4/2/16 Assignment 3 Version

More information

Package date. R topics documented: February 19, 2015. Version 1.2-34. Title Functions for handling dates. Description Functions for handling dates.

Package date. R topics documented: February 19, 2015. Version 1.2-34. Title Functions for handling dates. Description Functions for handling dates. Package date February 19, 2015 Version 1.2-34 Title Functions for handling dates Functions for handling dates. Imports graphics License GPL-2 Author Terry Therneau [aut], Thomas Lumley [trl] (R port),

More information

url.sty version 3.4 Donald Arseneau 2013-09-16

url.sty version 3.4 Donald Arseneau 2013-09-16 url.sty version 3.4 Donald Arseneau 2013-09-16 The package defines a form of \verb command that allows linebreaks at certain characters or combinations of characters, accepts reconfiguration, and can usually

More information

Data Storage STAT 133. Gaston Sanchez. Department of Statistics, UC Berkeley

Data Storage STAT 133. Gaston Sanchez. Department of Statistics, UC Berkeley Data Storage STAT 133 Gaston Sanchez Department of Statistics, UC Berkeley gastonsanchez.com github.com/gastonstat Course web: gastonsanchez.com/stat133 Data Storage 2 Awesome Resource Introduction to

More information

1 Posix API vs Windows API

1 Posix API vs Windows API 1 Posix API vs Windows API 1.1 File I/O Using the Posix API, to open a file, you use open(filename, flags, more optional flags). If the O CREAT flag is passed, the file will be created if it doesnt exist.

More information

Exploratory Data Analysis and Plotting

Exploratory Data Analysis and Plotting Exploratory Data Analysis and Plotting The purpose of this handout is to introduce you to working with and manipulating data in R, as well as how you can begin to create figures from the ground up. 1 Importing

More information

Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.

Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner. Handout 1 CS603 Object-Oriented Programming Fall 15 Page 1 of 11 Handout 1 Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner. Java

More information

Kit Rowley. Subject: Content type and workflow planning (SharePoint Server 2010) Attachments: image001.gif. Plan content types. Plan content types

Kit Rowley. Subject: Content type and workflow planning (SharePoint Server 2010) Attachments: image001.gif. Plan content types. Plan content types Kit Rowley Subject: Content type and workflow planning (SharePoint Server 2010) Attachments: image001.gif Content type and workflow planning (SharePoint Server 2010) Published: May 12, 2010 This article

More information

Psychology 205: Research Methods in Psychology

Psychology 205: Research Methods in Psychology Psychology 205: Research Methods in Psychology Using R to analyze the data for study 2 Department of Psychology Northwestern University Evanston, Illinois USA November, 2012 1 / 38 Outline 1 Getting ready

More information

Optimization of sampling strata with the SamplingStrata package

Optimization of sampling strata with the SamplingStrata package Optimization of sampling strata with the SamplingStrata package Package version 1.1 Giulio Barcaroli January 12, 2016 Abstract In stratified random sampling the problem of determining the optimal size

More information

Package dsstatsclient

Package dsstatsclient Maintainer Author Version 4.1.0 License GPL-3 Package dsstatsclient Title DataSHIELD client site stattistical functions August 20, 2015 DataSHIELD client site

More information

Introduction to the data.table package in R

Introduction to the data.table package in R Introduction to the data.table package in R Revised: September 18, 2015 (A later revision may be available on the homepage) Introduction This vignette is aimed at those who are already familiar with creating

More information

Introduction to the R Language

Introduction to the R Language Introduction to the R Language Functions Biostatistics 140.776 Functions Functions are created using the function() directive and are stored as R objects just like anything else. In particular, they are

More information

Search and Replace in SAS Data Sets thru GUI

Search and Replace in SAS Data Sets thru GUI Search and Replace in SAS Data Sets thru GUI Edmond Cheng, Bureau of Labor Statistics, Washington, DC ABSTRACT In managing data with SAS /BASE software, performing a search and replace is not a straight

More information

Lecture 5: Java Fundamentals III

Lecture 5: Java Fundamentals III Lecture 5: Java Fundamentals III School of Science and Technology The University of New England Trimester 2 2015 Lecture 5: Java Fundamentals III - Operators Reading: Finish reading Chapter 2 of the 2nd

More information

Save Actions User Guide

Save Actions User Guide Microsoft Dynamics CRM for Sitecore 6.6-8.0 Save Actions User Guide Rev: 2015-04-15 Microsoft Dynamics CRM for Sitecore 6.6-8.0 Save Actions User Guide A practical guide to using Microsoft Dynamics CRM

More information

Package DSsim. September 25, 2015

Package DSsim. September 25, 2015 Package DSsim September 25, 2015 Depends graphics, splancs, mrds, mgcv, shapefiles, methods Suggests testthat, parallel Type Package Title Distance Sampling Simulations Version 1.0.4 Date 2015-09-25 LazyLoad

More information

Classes for record linkage of big data sets

Classes for record linkage of big data sets Classes for record linkage of big data sets Andreas Borg, Murat Sariyar May 10, 2011 As of version 0., the package RecordLinkage includes extensions to overcome the problem of high memory consumption that

More information

Specifications of Paradox for Windows

Specifications of Paradox for Windows Specifications of Paradox for Windows Appendix A 1 Specifications of Paradox for Windows A IN THIS CHAPTER Borland Database Engine (BDE) 000 Paradox Standard Table Specifications 000 Paradox 5 Table Specifications

More information

Building and Using Web Services With JDeveloper 11g

Building and Using Web Services With JDeveloper 11g Building and Using Web Services With JDeveloper 11g Purpose In this tutorial, you create a series of simple web service scenarios in JDeveloper. This is intended as a light introduction to some of the

More information

1001ICT Introduction To Programming Lecture Notes

1001ICT Introduction To Programming Lecture Notes 1001ICT Introduction To Programming Lecture Notes School of Information and Communication Technology Griffith University Semester 2, 2015 1 3 A First MaSH Program In this section we will describe a very

More information

Package cgdsr. August 27, 2015

Package cgdsr. August 27, 2015 Type Package Package cgdsr August 27, 2015 Title R-Based API for Accessing the MSKCC Cancer Genomics Data Server (CGDS) Version 1.2.5 Date 2015-08-25 Author Anders Jacobsen Maintainer Augustin Luna

More information

Computing Concepts with Java Essentials

Computing Concepts with Java Essentials 2008 AGI-Information Management Consultants May be used for personal purporses only or by libraries associated to dandelon.com network. Computing Concepts with Java Essentials 3rd Edition Cay Horstmann

More information

HowTo: Querying online Data

HowTo: Querying online Data HowTo: Querying online Data Jeff Gentry and Robert Gentleman May 3, 2016 1 Overview This article demonstrates how you can make use of the tools that have been provided for on-line querying of data resources.

More information

Authoring for System Center 2012 Operations Manager

Authoring for System Center 2012 Operations Manager Authoring for System Center 2012 Operations Manager Microsoft Corporation Published: November 1, 2013 Authors Byron Ricks Applies To System Center 2012 Operations Manager System Center 2012 Service Pack

More information

Moving from CS 61A Scheme to CS 61B Java

Moving from CS 61A Scheme to CS 61B Java Moving from CS 61A Scheme to CS 61B Java Introduction Java is an object-oriented language. This document describes some of the differences between object-oriented programming in Scheme (which we hope you

More information

The R Environment. A high-level overview. Deepayan Sarkar. 22 July 2013. Indian Statistical Institute, Delhi

The R Environment. A high-level overview. Deepayan Sarkar. 22 July 2013. Indian Statistical Institute, Delhi The R Environment A high-level overview Deepayan Sarkar Indian Statistical Institute, Delhi 22 July 2013 The R language ˆ Tutorials in the Astrostatistics workshop will use R ˆ...in the form of silent

More information

Help on the Embedded Software Block

Help on the Embedded Software Block Help on the Embedded Software Block Powersim Inc. 1. Introduction The Embedded Software Block is a block that allows users to model embedded devices such as microcontrollers, DSP, or other devices. It

More information

Java Programming Fundamentals

Java Programming Fundamentals Lecture 1 Part I Java Programming Fundamentals Topics in Quantitative Finance: Numerical Solutions of Partial Differential Equations Instructor: Iraj Kani Introduction to Java We start by making a few

More information

awk A UNIX tool to manipulate and generate formatted data

awk A UNIX tool to manipulate and generate formatted data awk A UNIX tool to manipulate and generate formatted data Alexander Voigt Technische Universität Dresden Institut für Kern- und Teilchenphysik Version_05_21 /01234/546 78994: IKTP Computing Kaffee 10 January

More information

Package png. February 20, 2015

Package png. February 20, 2015 Version 0.1-7 Title Read and write PNG images Package png February 20, 2015 Author Simon Urbanek Maintainer Simon Urbanek Depends R (>= 2.9.0)

More information

PHP Magic Tricks: Type Juggling. PHP Magic Tricks: Type Juggling

PHP Magic Tricks: Type Juggling. PHP Magic Tricks: Type Juggling Who Am I Chris Smith (@chrismsnz) Previously: Polyglot Developer - Python, PHP, Go + more Linux Sysadmin Currently: Pentester, Consultant at Insomnia Security Little bit of research Insomnia Security Group

More information

STAT10020: Exploratory Data Analysis

STAT10020: Exploratory Data Analysis STAT10020: Exploratory Data Analysis Statistical Programming with R Lab 1 Log in using your student number and password. Click on the start button and then click on Application Window. Choose the Mathematics

More information

[MS-ASMS]: Exchange ActiveSync: Short Message Service (SMS) Protocol

[MS-ASMS]: Exchange ActiveSync: Short Message Service (SMS) Protocol [MS-ASMS]: Exchange ActiveSync: Short Message Service (SMS) Protocol Intellectual Property Rights Notice for Open Specifications Documentation Technical Documentation. Microsoft publishes Open Specifications

More information

CS 111 Classes I 1. Software Organization View to this point:

CS 111 Classes I 1. Software Organization View to this point: CS 111 Classes I 1 Software Organization View to this point: Data Objects and primitive types Primitive types operators (+, /,,*, %). int, float, double, char, boolean Memory location holds the data Objects

More information

ASCII Encoding. The char Type. Manipulating Characters. Manipulating Characters

ASCII Encoding. The char Type. Manipulating Characters. Manipulating Characters The char Type ASCII Encoding The C char type stores small integers. It is usually 8 bits. char variables guaranteed to be able to hold integers 0.. +127. char variables mostly used to store characters

More information

Using self-organizing maps for visualization and interpretation of cytometry data

Using self-organizing maps for visualization and interpretation of cytometry data 1 Using self-organizing maps for visualization and interpretation of cytometry data Sofie Van Gassen, Britt Callebaut and Yvan Saeys Ghent University September, 2014 Abstract The FlowSOM package provides

More information

1. Classification problems

1. Classification problems Neural and Evolutionary Computing. Lab 1: Classification problems Machine Learning test data repository Weka data mining platform Introduction Scilab 1. Classification problems The main aim of a classification

More information

Practical Differential Gene Expression. Introduction

Practical Differential Gene Expression. Introduction Practical Differential Gene Expression Introduction In this tutorial you will learn how to use R packages for analysis of differential expression. The dataset we use are the gene-summarized count data

More information

An Incomplete C++ Primer. University of Wyoming MA 5310

An Incomplete C++ Primer. University of Wyoming MA 5310 An Incomplete C++ Primer University of Wyoming MA 5310 Professor Craig C. Douglas http://www.mgnet.org/~douglas/classes/na-sc/notes/c++primer.pdf C++ is a legacy programming language, as is other languages

More information

White Paper. Fabasoft app.test Load Testing. Fabasoft app.test 2015 Update Rollup 2. Fabasoft app.test Load Testing 1

White Paper. Fabasoft app.test Load Testing. Fabasoft app.test 2015 Update Rollup 2. Fabasoft app.test Load Testing 1 White Paper Fabasoft app.test Load Testing Fabasoft app.test 2015 Update Rollup 2 Fabasoft app.test Load Testing 1 Copyright Fabasoft R&D GmbH, Linz, Austria, 2015. All rights reserved. All hardware and

More information

2 intervals-package. Index 33. Tools for working with points and intervals

2 intervals-package. Index 33. Tools for working with points and intervals Package intervals March 7, 2013 Version 0.14.0 Date 2013-03-06 Type Package Title Tools for working with points and intervals Author Richard Bourgon Maintainer Richard Bourgon

More information

Model Driven Laboratory Information Management Systems Hao Li 1, John H. Gennari 1, James F. Brinkley 1,2,3 Structural Informatics Group 1

Model Driven Laboratory Information Management Systems Hao Li 1, John H. Gennari 1, James F. Brinkley 1,2,3 Structural Informatics Group 1 Model Driven Laboratory Information Management Systems Hao Li 1, John H. Gennari 1, James F. Brinkley 1,2,3 Structural Informatics Group 1 Biomedical and Health Informatics, 2 Computer Science and Engineering,

More information

Package RCassandra. R topics documented: February 19, 2015. Version 0.1-3 Title R/Cassandra interface

Package RCassandra. R topics documented: February 19, 2015. Version 0.1-3 Title R/Cassandra interface Version 0.1-3 Title R/Cassandra interface Package RCassandra February 19, 2015 Author Simon Urbanek Maintainer Simon Urbanek This packages provides

More information

Introduction of geospatial data visualization and geographically weighted reg

Introduction of geospatial data visualization and geographically weighted reg Introduction of geospatial data visualization and geographically weighted regression (GWR) Vanderbilt University August 16, 2012 Study Background Study Background Data Overview Algorithm (1) Information

More information

Basics of I/O Streams and File I/O

Basics of I/O Streams and File I/O Basics of This is like a cheat sheet for file I/O in C++. It summarizes the steps you must take to do basic I/O to and from files, with only a tiny bit of explanation. It is not a replacement for reading

More information

Introduction to Matlab

Introduction to Matlab Introduction to Matlab Social Science Research Lab American University, Washington, D.C. Web. www.american.edu/provost/ctrl/pclabs.cfm Tel. x3862 Email. SSRL@American.edu Course Objective This course provides

More information

Sources: On the Web: Slides will be available on:

Sources: On the Web: Slides will be available on: C programming Introduction The basics of algorithms Structure of a C code, compilation step Constant, variable type, variable scope Expression and operators: assignment, arithmetic operators, comparison,

More information

Classes and Methods for Spatial Data: the sp Package

Classes and Methods for Spatial Data: the sp Package Classes and Methods for Spatial Data: the sp Package Edzer Pebesma Roger S. Bivand Feb 2005 Contents 1 Introduction 2 2 Spatial data classes 2 3 Manipulating spatial objects 3 3.1 Standard methods..........................

More information

Basic Programming and PC Skills: Basic Programming and PC Skills:

Basic Programming and PC Skills: Basic Programming and PC Skills: Texas University Interscholastic League Contest Event: Computer Science The contest challenges high school students to gain an understanding of the significance of computation as well as the details of

More information

Member Functions of the istream Class

Member Functions of the istream Class Member Functions of the istream Class The extraction operator is of limited use because it always uses whitespace to delimit its reads of the input stream. It cannot be used to read those whitespace characters,

More information

Implementing a WCF Service in the Real World

Implementing a WCF Service in the Real World Implementing a WCF Service in the Real World In the previous chapter, we created a basic WCF service. The WCF service we created, HelloWorldService, has only one method, called GetMessage. Because this

More information

Python Lists and Loops

Python Lists and Loops WEEK THREE Python Lists and Loops You ve made it to Week 3, well done! Most programs need to keep track of a list (or collection) of things (e.g. names) at one time or another, and this week we ll show

More information

Package neuralnet. February 20, 2015

Package neuralnet. February 20, 2015 Type Package Title Training of neural networks Version 1.32 Date 2012-09-19 Package neuralnet February 20, 2015 Author Stefan Fritsch, Frauke Guenther , following earlier work

More information

Basic Java Constructs and Data Types Nuts and Bolts. Looking into Specific Differences and Enhancements in Java compared to C

Basic Java Constructs and Data Types Nuts and Bolts. Looking into Specific Differences and Enhancements in Java compared to C Basic Java Constructs and Data Types Nuts and Bolts Looking into Specific Differences and Enhancements in Java compared to C 1 Contents Hello World Program Statements Explained Java Program Structure in

More information

A Handbook of Statistical Analyses Using R. Brian S. Everitt and Torsten Hothorn

A Handbook of Statistical Analyses Using R. Brian S. Everitt and Torsten Hothorn A Handbook of Statistical Analyses Using R Brian S. Everitt and Torsten Hothorn CHAPTER 1 An Introduction to R 1.1 What is R? The R system for statistical computing is an environment for data analysis

More information

Storage Classes CS 110B - Rule Storage Classes Page 18-1 \handouts\storclas

Storage Classes CS 110B - Rule Storage Classes Page 18-1 \handouts\storclas CS 110B - Rule Storage Classes Page 18-1 Attributes are distinctive features of a variable. Data type, int or double for example, is an attribute. Storage class is another attribute. There are four storage

More information

Informatica e Sistemi in Tempo Reale

Informatica e Sistemi in Tempo Reale Informatica e Sistemi in Tempo Reale Introduction to C programming Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 25, 2010 G. Lipari (Scuola Superiore Sant Anna)

More information

Package GEOquery. August 18, 2015

Package GEOquery. August 18, 2015 Type Package Package GEOquery August 18, 2015 Title Get data from NCBI Gene Expression Omnibus (GEO) Version 2.34.0 Date 2014-09-28 Author Maintainer BugReports

More information

09336863931 : provid.ir

09336863931 : provid.ir provid.ir 09336863931 : NET Architecture Core CSharp o Variable o Variable Scope o Type Inference o Namespaces o Preprocessor Directives Statements and Flow of Execution o If Statement o Switch Statement

More information

An Introduction to R. W. N. Venables, D. M. Smith and the R Core Team

An Introduction to R. W. N. Venables, D. M. Smith and the R Core Team An Introduction to R Notes on R: A Programming Environment for Data Analysis and Graphics Version 3.1.1 (2014-07-10) W. N. Venables, D. M. Smith and the R Core Team This manual is for R, version 3.1.1

More information

Your Best Next Business Solution Big Data In R 24/3/2010

Your Best Next Business Solution Big Data In R 24/3/2010 Your Best Next Business Solution Big Data In R 24/3/2010 Big Data In R R Works on RAM Causing Scalability issues Maximum length of an object is 2^31-1 Some packages developed to help overcome this problem

More information

Example of a Java program

Example of a Java program Example of a Java program class SomeNumbers static int square (int x) return x*x; public static void main (String[] args) int n=20; if (args.length > 0) // change default n = Integer.parseInt(args[0]);

More information

Online signature API. Terms used in this document. The API in brief. Version 0.20, 2015-04-08

Online signature API. Terms used in this document. The API in brief. Version 0.20, 2015-04-08 Online signature API Version 0.20, 2015-04-08 Terms used in this document Onnistuu.fi, the website https://www.onnistuu.fi/ Client, online page or other system using the API provided by Onnistuu.fi. End

More information