Sub-setting Data. Tzu L. Phang

Size: px
Start display at page:

Download "Sub-setting Data. Tzu L. Phang"

Transcription

1 Sub-setting Data Tzu L. Phang

2 Subsetting in R Let s start with a (dummy) vectors. x <- c(5.4, 6.2, 7.1, 4.8, 7.5) names(x) <- c('a', 'b', 'c', 'd', 'e') x

3 Accessing elements using their indices Using indices x[1] x[4] Using a series of indices x[c(1, 3)] Or slices of the vector: x[1:4]

4 Warning But, if outside... return nothing... x[6] If we ask for the 0th element, we get an empty vector: x[0]

5 Skipping and removing elements Negative number: return all except that: x[-2] We can skip multiple elements: x[c(-1, -5)] # or x[-c(1,5)]

6 Challenge 1 Given the following code: x <- c(5.4, 6.2, 7.1, 4.8, 7.5) names(x) <- c("a", "b", "c", "d", "e") print(x) Come up with at least 3 different commands that will produce the following output: x[2:4]

7 Solution to challenge 1 x[2:4] x[-c(1, 5)] x[c("b", "c", "d")] x[c(2, 3, 4)]

8 Subsetting by name extracting by name: x[c("a", "c")] To skip (or remove) a single named element: x[-which(names(x) == "a")]

9 Skipping Multiple Named Indices Skipping multiple named indices: x[-which(names(x) %in% c("a", "c"))] The %in% goes through each element of its left argument, in this case the names of x, and asks, Does this element occur in the second argument?.

10 Subsetting through other logical operations Subset through logical operations: x[c(true, TRUE, FALSE, FALSE)] Logical vector is also recycled: x[c(true, FALSE)]

11 Combining logical conditions Combine multiple logical criteria. & &&, the logical AND operator: returns TRUE if both the left and right are TRUE., the logical OR operator: returns TRUE, if either the left or right (or both) are TRUE.!, the logical NOT operator: converts TRUE to FALSE and FALSE to TRUE. It can negate a single logical condition (eg!true becomes FALSE), or a whole vector of conditions(eg!c(true, FALSE) becomes c(false, TRUE)). all, Which returns TRUE if every element of the vector is TRUE any, Which returns TRUE if one or more elements of the vector are TRUE

12 Challenge 3 Given the following code: x <- c(5.4, 6.2, 7.1, 4.8, 7.5) names(x) <- c("a", "b", "c", "d", "e") print(x) Write a subsetting command to return the values in x that are greater than 4 and less than 7.

13 Solution to challenge 3 x_subset <- x[x < 7 & x > 4] print(x_subset)

14 Handling special values There are a number of special functions you can use to filter out this data: is.na will return all positions in a vector, matrix, or data.frame containing NA. is.nan will do for NaN is.infinite will do for Inf is.finite will return all positions in a vector, matrix, or data.frame that do not contain NA, NaN or Inf. na.omit will filter out all missing values from a vector

15 Factor subsetting Factor subsetting works the same way as vector subsetting. f <- factor(c("a", "a", "b", "c", "c", "d")) f[f == "a"] f[f %in% c("b", "c")] f[1:3] An important note is that skipping elements will not remove the level even if no more of that category exists in the factor: f[-3]

16 Matrix subsetting Matrices are also subsetted using the [ function. It takes two arguments: the first applying to the rows the second to its columns: set.seed(1) m <- matrix(rnorm(6*4), ncol=4, nrow=6) m[3:4, c(3,1)] You can leave the first or second arguments blank to retrieve all the rows or columns respectively: m[, c(3,4)] If we only access one row or column, R will automatically convert the result to a vector: m[3,]

17 Matrix subsetting... cont... If you want to keep the output as a matrix, you need to specify a third argument; drop = FALSE: m[3,, drop=false] Unlike vectors, if we try to access a row or column outside of the matrix, R will throw an error: m[, c(3,6)]

18 Matric: assign by column Matrices are laid out in column-major format by default. matrix(1:6, nrow=2, ncol=3) If you wish to populate the matrix by row, use byrow=true: matrix(1:6, nrow=2, ncol=3, byrow=true)

19 Challenge 4 Given the following code: m <- matrix(1:18, nrow=3, ncol=6) print(m) ## [,1] [,2] [,3] [,4] [,5] [,6] ## [1,] ## [2,] ## [3,] Which of the following commands will extract the values 11 and 14? A. m[2,4,2,5] B. m[2:5] C. m[4:5,2] D. m[2,c(4,5)]

20 Solution to challenge 4 D

21 List subsetting There are three functions used to subset lists. [: will subset a list [[: will subset the element of the list $: will subset the element by name xlist <- list(a = "Software Carpentry", b = 1:10, data = head(iris)) xlist[1] xlist[[1]] xlist[['a']] xlist$a

22 Subset list limitation You can t extract more than one element at once: xlist[[1:2]] Nor use it to skip elements: > xlist[[-1]]

23 Challenge 5 Given the following list: xlist <- list(a = "Software Carpentry", b = 1:10, data = head(iris)) Using your knowledge of both list and vector subsetting, extract the number 2 from xlist. Hint: the number 2 is contained within the b item in the list.

24 Solution to challenge 5 xlist$b[2] xlist[[2]][2] xlist[["b"]][2]

25 Challenge 6 Given a linear model: mod <- aov(pop ~ lifeexp, data=gapminder) Extract the residual degrees of freedom (hint: attributes() will help you)

26 Solution to challenge 6 attributes(mod) ## `df.residual` is one of the names of `mod` mod$df.residual

27 Gapminder: Life Expectancy GapMinder Video: let s watch... Lets read in the gapminder dataset that we downloaded previously: gapminder <- read.csv("data/gapminder-fiveyeardata.csv")

28 Data frames: practice with gapminder dataset Fix each of the following common data frame subsetting errors: 1. Extract observations collected for the year 1957 gapminder[gapminder$year == 1957,] 2. Extract all columns except 1 through to 4 gapminder[,-c(1:4)] 3. Extract the rows where the life expectancy is longer the 80 years gapminder[gapminder$lifeexp > 80,]

29 Data frames: practice with gapminder dataset... cont Extract the first row, and the fourth and fifth columns (lifeexp and gdppercap). gapminder[1, c(4, 5)] 5. Advanced: extract rows that contain information for the years 2002 and 2007 gapminder[gapminder$year == 2002 gapminder$year == 2007,] gapminder[gapminder$year %in% c(2002, 2007),]

Introduction to the R Language

Introduction to the R Language Introduction to the R Language Data Types and Basic Operations Starting Up Windows: Double-click on R Mac OS X: Click on R Unix: Type R Objects R has five basic or atomic classes of objects: character

More information

Stat 579: Objects in R Vectors

Stat 579: Objects in R Vectors Stat 579: Objects in R Vectors Ranjan Maitra 2220 Snedecor Hall Department of Statistics Iowa State University. Phone: 515-294-7757 maitra@iastate.edu, 1/23 Logical Vectors I R allows manipulation of logical

More information

SML 201 Week 2 John D. Storey Spring 2016

SML 201 Week 2 John D. Storey Spring 2016 SML 201 Week 2 John D. Storey Spring 2016 Contents Getting Started in R 3 Summary from Week 1.......................... 3 Missing Values.............................. 3 NULL....................................

More information

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

Data Structures STAT 133. Gaston Sanchez. Department of Statistics, UC Berkeley Data Structures STAT 133 Gaston Sanchez Department of Statistics, UC Berkeley gastonsanchez.com github.com/gastonstat/stat133 Course web: gastonsanchez.com/stat133 Data Types and Structures To make the

More information

the R environment The R language is an integrated suite of software facilities for:

the R environment The R language is an integrated suite of software facilities for: the R environment The R language is an integrated suite of software facilities for: Data Handling and storage Matrix Math: Manipulating matrices, vectors, and arrays Statistics: A large, integrated set

More information

Week 4. Big Data Analytics - data.frame manipulation with dplyr

Week 4. Big Data Analytics - data.frame manipulation with dplyr Week 4. Big Data Analytics - data.frame manipulation with dplyr Hyeonsu B. Kang hyk149@eng.ucsd.edu April 2016 1 Dplyr In the last lecture we have seen how to index an individual cell in a data frame,

More information

Introduction to R. Nishant Gopalakrishnan, Martin Morgan January, Fred Hutchinson Cancer Research Center

Introduction to R. Nishant Gopalakrishnan, Martin Morgan January, Fred Hutchinson Cancer Research Center Introduction to R Nishant Gopalakrishnan, Martin Morgan Fred Hutchinson Cancer Research Center 19-21 January, 2011 Getting Started Atomic Data structures Creating vectors Subsetting vectors Factors Matrices

More information

Control Flow Structures

Control Flow Structures Control Flow Structures STAT 133 Gaston Sanchez Department of Statistics, UC Berkeley gastonsanchez.com github.com/gastonstat/stat133 Course web: gastonsanchez.com/stat133 Expressions 2 Expressions R code

More information

Programming with R. Bjørn-Helge Mevik. RIS Course Week spring Research Infrastructure Services Group, USIT, UiO

Programming with R. Bjørn-Helge Mevik. RIS Course Week spring Research Infrastructure Services Group, USIT, UiO Programming with R Bjørn-Helge Mevik Research Infrastructure Services Group, USIT, UiO RIS Course Week spring 2014 Bjørn-Helge Mevik (RIS) Programming with R Course Week spring 2014 1 / 27 Introduction

More information

CS Introduction to Computational and Data Science. Instructor: Renzhi Cao Computer Science Department Pacific Lutheran University Spring 2017

CS Introduction to Computational and Data Science. Instructor: Renzhi Cao Computer Science Department Pacific Lutheran University Spring 2017 CS 133 - Introduction to Computational and Data Science Instructor: Renzhi Cao Computer Science Department Pacific Lutheran University Spring 2017 Announcement Read book to page 44. Final project Today

More information

6 Subscripting. 6.1 Basics of Subscripting. 6.2 Numeric Subscripts. 6.3 Character Subscripts

6 Subscripting. 6.1 Basics of Subscripting. 6.2 Numeric Subscripts. 6.3 Character Subscripts 6 Subscripting 6.1 Basics of Subscripting For objects that contain more than one element (vectors, matrices, arrays, data frames, and lists), subscripting is used to access some or all of those elements.

More information

Basic matrix math in R

Basic matrix math in R 1 Basic matrix math in R This chapter reviews the basic matrix math operations that you will need to understand the course material and how to do these operations in R. 1.1 Creating matrices in R Create

More information

Description/History Objects/Language Description Commonly Used Basic Functions. More Specific Functionality Further Resources

Description/History Objects/Language Description Commonly Used Basic Functions. More Specific Functionality Further Resources R Outline Description/History Objects/Language Description Commonly Used Basic Functions Basic Stats and distributions I/O Plotting Programming More Specific Functionality Further Resources www.r-project.org

More information

R and parallel libraries. Introduction to R for data analytics Bologna, 26/06/2017

R and parallel libraries. Introduction to R for data analytics Bologna, 26/06/2017 R and parallel libraries Introduction to R for data analytics Bologna, 26/06/2017 Outline Overview What is R R Console Input and Evaluation Data types R Objects and Attributes Vectors and Lists Matrices

More information

R basics workshop Sohee Kang

R basics workshop Sohee Kang R basics workshop Sohee Kang Math and Stats Learning Centre Department of Computer and Mathematical Sciences Objective To teach the basic knowledge necessary to use R independently, thus helping participants

More information

Introducion to R and parallel libraries. Giorgio Pedrazzi, CINECA Matteo Sartori, CINECA School of Data Analytics and Visualisation Milan, 09/06/2015

Introducion to R and parallel libraries. Giorgio Pedrazzi, CINECA Matteo Sartori, CINECA School of Data Analytics and Visualisation Milan, 09/06/2015 Introducion to R and parallel libraries Giorgio Pedrazzi, CINECA Matteo Sartori, CINECA School of Data Analytics and Visualisation Milan, 09/06/2015 Overview What is R R Console Input and Evaluation Data

More information

CS 61A, Fall, 2002, Midterm #2, L. Rowe. 1. (10 points, 1 point each part) Consider the following five box-and-arrow diagrams.

CS 61A, Fall, 2002, Midterm #2, L. Rowe. 1. (10 points, 1 point each part) Consider the following five box-and-arrow diagrams. CS 61A, Fall, 2002, Midterm #2, L. Rowe 1. (10 points, 1 point each part) Consider the following five box-and-arrow diagrams. a) d) 3 1 2 3 1 2 e) b) 3 c) 1 2 3 1 2 1 2 For each of the following Scheme

More information

UTORid: Comments are not required except where indicated, although they may help us mark your answers.

UTORid: Comments are not required except where indicated, although they may help us mark your answers. CSC 121H1 S 2018 Quiz 2 (Version B) March 19, 2018 Duration 35 minutes Aids allowed: none Last Name: Lecture Section: Instructor: UTORid: First Name: L0101 (MWF12) Mark Kazakevich Do not turn this page

More information

Package keep. R topics documented: December 16, 2015

Package keep. R topics documented: December 16, 2015 Package keep December 16, 2015 Type Package Title Arrays with Better Control over Dimension Dropping Version 1.0 Date 2015-12-11 Author Paavo Jumppanen Maintainer Paavo Jumppanen

More information

C/C++ Programming for Engineers: Matlab Branches and Loops

C/C++ Programming for Engineers: Matlab Branches and Loops C/C++ Programming for Engineers: Matlab Branches and Loops John T. Bell Department of Computer Science University of Illinois, Chicago Review What is the difference between a script and a function in Matlab?

More information

Introduction to R Forecasting Techniques

Introduction to R Forecasting Techniques Introduction to R zabbeta@fsu.gr katerina@fsu.gr Starting out in R Working with data Plotting & Forecasting 1. Starting Out In R R & RStudio Variables & Basics Data Types Functions R + RStudio Programming

More information

13. Section 9 Exercises

13. Section 9 Exercises 13 Section 9 Exercises Exercise 9-1: The matrix m is an array of 4 arrays, each with 6 members If m is regarded as a 2- dimensional array, then m[1][2] is m[2][5] is m[4][1] is m[3] is 73 Program Memory

More information

Statistical Computing (36-350)

Statistical Computing (36-350) Statistical Computing (36-350) Lecture 1: Introduction to the course; Data Cosma Shalizi and Vincent Vu 29 August 2011 Why good statisticians learn how to program Independence: otherwise, you rely on someone

More information

R (and S, and S-Plus, another program based on S) is an interactive, interpretive, function language.

R (and S, and S-Plus, another program based on S) is an interactive, interpretive, function language. R R (and S, and S-Plus, another program based on S) is an interactive, interpretive, function language. Available on Linux, Unix, Mac, and MS Windows systems. Documentation exists in several volumes, and

More information

Lab #10 Multi-dimensional Arrays

Lab #10 Multi-dimensional Arrays Multi-dimensional Arrays Sheet s Owner Student ID Name Signature Group partner 1. Two-Dimensional Arrays Arrays that we have seen and used so far are one dimensional arrays, where each element is indexed

More information

Package slam. February 15, 2013

Package slam. February 15, 2013 Package slam February 15, 2013 Version 0.1-28 Title Sparse Lightweight Arrays and Matrices Data structures and algorithms for sparse arrays and matrices, based on inde arrays and simple triplet representations,

More information

Programming with R. Educational Materials 2006 S. Falcon, R. Ihaka, and R. Gentleman

Programming with R. Educational Materials 2006 S. Falcon, R. Ihaka, and R. Gentleman Programming with R Educational Materials 2006 S. Falcon, R. Ihaka, and R. Gentleman 1 Data Structures ˆ R has a rich set of self-describing data structures. > class(z) [1] "character" > class(x) [1] "data.frame"

More information

Programming with R. Educational Materials 2006 S. Falcon, R. Ihaka, and R. Gentleman

Programming with R. Educational Materials 2006 S. Falcon, R. Ihaka, and R. Gentleman Programming with R Educational Materials 2006 S. Falcon, R. Ihaka, and R. Gentleman 1 Data Structures ˆ R has a rich set of self-describing data structures. > class(z) [1] "character" > class(x) [1] "data.frame"

More information

ITS Introduction to R course

ITS Introduction to R course ITS Introduction to R course Nov. 29, 2018 Using this document Code blocks and R code have a grey background (note, code nested in the text is not highlighted in the pdf version of this document but is

More information

Package slam. December 1, 2016

Package slam. December 1, 2016 Version 0.1-40 Title Sparse Lightweight Arrays and Matrices Package slam December 1, 2016 Data structures and algorithms for sparse arrays and matrices, based on inde arrays and simple triplet representations,

More information

Basic R Part 1 BTI Plant Bioinformatics Course

Basic R Part 1 BTI Plant Bioinformatics Course Basic R Part 1 BTI Plant Bioinformatics Course Spring 2013 Sol Genomics Network Boyce Thompson Institute for Plant Research by Jeremy D. Edwards What is R? Statistical programming language Derived from

More information

Handling Missing Values

Handling Missing Values Handling Missing Values STAT 133 Gaston Sanchez Department of Statistics, UC Berkeley gastonsanchez.com github.com/gastonstat/stat133 Course web: gastonsanchez.com/stat133 Missing Values 2 Introduction

More information

The R.huge Package. September 1, 2007

The R.huge Package. September 1, 2007 The R.huge Package September 1, 2007 Version 0.1.5 Date 2006-08-29 Title Methods for accessing huge amounts of data Author Henrik Bengtsson Maintainer Henrik Bengtsson

More information

An Introduction to R for Epidemiologists using RStudio

An Introduction to R for Epidemiologists using RStudio An Introduction to R for Epidemiologists using RStudio indexing Steve Mooney, stealing heavily from C. DiMaggio Department of Epidemiology Columbia University New York, NY 10032 sjm2186@columbia.edu An

More information

Package crochet. January 8, 2018

Package crochet. January 8, 2018 Version 2.0.1 License MIT + file LICENSE Package crochet January 8, 2018 Title Implementation Helper for [ and [

More information

Introduction to R, Github and Gitlab

Introduction to R, Github and Gitlab Introduction to R, Github and Gitlab 27/11/2018 Pierpaolo Maisano Delser mail: maisanop@tcd.ie ; pm604@cam.ac.uk Outline: Why R? What can R do? Basic commands and operations Data analysis in R Github and

More information

Lecture 06: Feb 04, Transforming Data. Functions Classes and Objects Vectorization Subsets. James Balamuta STAT UIUC

Lecture 06: Feb 04, Transforming Data. Functions Classes and Objects Vectorization Subsets. James Balamuta STAT UIUC Lecture 06: Feb 04, 2019 Transforming Data Functions Classes and Objects Vectorization Subsets James Balamuta STAT 385 @ UIUC Announcements hw02 is will be released Tonight Due on Wednesday, Feb 13th,

More information

Name: THE SIMPLEX METHOD: STANDARD MAXIMIZATION PROBLEMS

Name: THE SIMPLEX METHOD: STANDARD MAXIMIZATION PROBLEMS Name: THE SIMPLEX METHOD: STANDARD MAXIMIZATION PROBLEMS A linear programming problem consists of a linear objective function to be maximized or minimized subject to certain constraints in the form of

More information

Weighted Powers Ranking Method

Weighted Powers Ranking Method Weighted Powers Ranking Method Introduction The Weighted Powers Ranking Method is a method for ranking sports teams utilizing both number of teams, and strength of the schedule (i.e. how good are the teams

More information

Entering and Outputting Data 2 nd best TA ever: Steele H. Valenzuela February 2-6, 2015

Entering and Outputting Data 2 nd best TA ever: Steele H. Valenzuela February 2-6, 2015 Entering and Outputting Data 2 nd best TA ever: Steele H. Valenzuela February 2-6, 2015 Contents Things to Know Before You Begin.................................... 1 Entering and Outputting Data......................................

More information

R is a programming language of a higher-level Constantly increasing amount of packages (new research) Free of charge Website:

R is a programming language of a higher-level Constantly increasing amount of packages (new research) Free of charge Website: Introduction to R R R is a programming language of a higher-level Constantly increasing amount of packages (new research) Free of charge Website: http://www.r-project.org/ Code Editor: http://rstudio.org/

More information

Overview. Linear Algebra Notation. MATLAB Data Types Data Visualization. Probability Review Exercises. Asymptotics (Big-O) Review

Overview. Linear Algebra Notation. MATLAB Data Types Data Visualization. Probability Review Exercises. Asymptotics (Big-O) Review Tutorial 1 1 / 21 Overview Linear Algebra Notation Data Types Data Visualization Probability Review Exercises Asymptotics (Big-O) Review 2 / 21 Linear Algebra Notation Notation and Convention 3 / 21 Linear

More information

Introduction to R. Educational Materials 2007 S. Falcon, R. Ihaka, and R. Gentleman

Introduction to R. Educational Materials 2007 S. Falcon, R. Ihaka, and R. Gentleman Introduction to R Educational Materials 2007 S. Falcon, R. Ihaka, and R. Gentleman 1 Data Structures ˆ R has a rich set of self-describing data structures. > class(z) [1] "character" > class(x) [1] "data.frame"

More information

Package blockmatrix. February 19, 2015

Package blockmatrix. February 19, 2015 Package blockmatrix February 19, 2015 aintainer License GPL (>= 2) Title blockmatrix: Tools to solve algebraic systems with partitioned matrices Type Package Author Some elementary

More information

Matrix algebra. Basics

Matrix algebra. Basics Matrix.1 Matrix algebra Matrix algebra is very prevalently used in Statistics because it provides representations of models and computations in a much simpler manner than without its use. The purpose of

More information

Reading and wri+ng data

Reading and wri+ng data An introduc+on to Reading and wri+ng data Noémie Becker & Benedikt Holtmann Winter Semester 16/17 Course outline Day 4 Course outline Review Data types and structures Reading data How should data look

More information

Data Frames and Control September 2014

Data Frames and Control September 2014 Data Frames and Control 36-350 3 September 2014 Agenda Making and working with data frames Conditionals: switching between different calculations Iteration: Doing something over and over Vectorizing: Avoiding

More information

Package LSDinterface

Package LSDinterface Type Package Title Reading LSD Results (.res) Files Version 0.3.1 Date 2017-11-24 Author Package LSDinterface November 27, 2017 Maintainer Interfaces R with LSD. Reads object-oriented

More information

Lecture 3: Basics of R Programming

Lecture 3: Basics of R Programming Lecture 3: Basics of R Programming This lecture introduces you to how to do more things with R beyond simple commands. Outline: 1. R as a programming language 2. Grouping, loops and conditional execution

More information

command.name(measurement, grouping, argument1=true, argument2=3, argument3= word, argument4=c( A, B, C ))

command.name(measurement, grouping, argument1=true, argument2=3, argument3= word, argument4=c( A, B, C )) Tutorial 3: Data Manipulation Anatomy of an R Command Every command has a unique name. These names are specific to the program and case-sensitive. In the example below, command.name is the name of the

More information

Introduction to R: Data Types

Introduction to R: Data Types Introduction to R: Data Types https://ivanek.github.io/introductiontor/ Florian Geier (florian.geier@unibas.ch) September 26, 2018 Recapitulation Possible workspaces Install R & RStudio on your laptop

More information

Introduction to R. Stat Statistical Computing - Summer Dr. Junvie Pailden. July 5, Southern Illinois University Edwardsville

Introduction to R. Stat Statistical Computing - Summer Dr. Junvie Pailden. July 5, Southern Illinois University Edwardsville Introduction to R Stat 575 - Statistical Computing - Summer 2016 Dr. Junvie Pailden Southern Illinois University Edwardsville July 5, 2016 Why R R offers a powerful and appealing interactive environment

More information

Program Development (SAS IML)

Program Development (SAS IML) Program Development (SAS IML) τρ 1 Review SAS IML Functions for generating matrix BLOCK Function I Function J Function REPEAT Function SHAPE Function 2 BLOCK Forms block-diagonal matrices The BLOCK function

More information

Package assertr. R topics documented: February 23, Type Package

Package assertr. R topics documented: February 23, Type Package Type Package Package assertr February 23, 2018 Title Assertive Programming for R Analysis Pipelines Version 2.5 Provides functionality to assert conditions that have to be met so that errors in data used

More information

STENO Introductory R-Workshop: Loading a Data Set Tommi Suvitaival, Steno Diabetes Center June 11, 2015

STENO Introductory R-Workshop: Loading a Data Set Tommi Suvitaival, Steno Diabetes Center June 11, 2015 STENO Introductory R-Workshop: Loading a Data Set Tommi Suvitaival, tsvv@steno.dk, Steno Diabetes Center June 11, 2015 Contents 1 Introduction 1 2 Recap: Variables 2 3 Data Containers 2 3.1 Vectors................................................

More information

Functions and data structures. Programming in R for Data Science Anders Stockmarr, Kasper Kristensen, Anders Nielsen

Functions and data structures. Programming in R for Data Science Anders Stockmarr, Kasper Kristensen, Anders Nielsen Functions and data structures Programming in R for Data Science Anders Stockmarr, Kasper Kristensen, Anders Nielsen Objects of the game In R we have objects which are functions and objects which are data.

More information

Package ibbig. R topics documented: December 24, 2018

Package ibbig. R topics documented: December 24, 2018 Type Package Title Iterative Binary Biclustering of Genesets Version 1.26.0 Date 2011-11-23 Author Daniel Gusenleitner, Aedin Culhane Package ibbig December 24, 2018 Maintainer Aedin Culhane

More information

Package matchingr. January 26, 2018

Package matchingr. January 26, 2018 Type Package Title Matching Algorithms in R and C++ Version 1.3.0 Date 2018-01-26 Author Jan Tilly, Nick Janetos Maintainer Jan Tilly Package matchingr January 26, 2018 Computes matching

More information

Package tibble. August 22, 2017

Package tibble. August 22, 2017 Encoding UTF-8 Version 1.3.4 Title Simple Data Frames Package tibble August 22, 2017 Provides a 'tbl_df' class (the 'tibble') that provides stricter checking and better formatting than the traditional

More information

Introduction to the R Language

Introduction to the R Language Introduction to the R Language Loop Functions Biostatistics 140.776 1 / 32 Looping on the Command Line Writing for, while loops is useful when programming but not particularly easy when working interactively

More information

STAT 540: R: Sections Arithmetic in R. Will perform these on vectors, matrices, arrays as well as on ordinary numbers

STAT 540: R: Sections Arithmetic in R. Will perform these on vectors, matrices, arrays as well as on ordinary numbers Arithmetic in R R can be viewed as a very fancy calculator Can perform the ordinary mathematical operations: + - * / ˆ Will perform these on vectors, matrices, arrays as well as on ordinary numbers With

More information

The grplasso Package

The grplasso Package The grplasso Package June 27, 2007 Type Package Title Fitting user specified models with Group Lasso penalty Version 0.2-1 Date 2007-06-27 Author Lukas Meier Maintainer Lukas Meier

More information

Package nos. September 11, 2017

Package nos. September 11, 2017 Type Package Package nos September 11, 2017 Title Compute Node Overlap and Segregation in Ecological Networks Version 1.1.0 Author Thomas J. Matthews and Giovanni Strona Maintainer Thomas J. Matthews

More information

lecture 2: a crash course in r

lecture 2: a crash course in r lecture 2: a crash course in r STAT 545: Introduction to computational statistics Vinayak Rao Department of Statistics, Purdue University August 20, 2018 The programming language From the manual, is a

More information

The MAXQDA Stats Data Editor

The MAXQDA Stats Data Editor The Data Editor The Data Editor The MAXQDA Stats Data Editor displays the cases in the rows and the variables in the columns. Each case is therefore in a separate line. The following figure shows the Data

More information

Package logspline. February 3, 2016

Package logspline. February 3, 2016 Version 2.1.9 Date 2016-02-01 Title Logspline Density Estimation Routines Package logspline February 3, 2016 Author Charles Kooperberg Maintainer Charles Kooperberg

More information

Package JBTools. R topics documented: June 2, 2015

Package JBTools. R topics documented: June 2, 2015 Package JBTools June 2, 2015 Title Misc Small Tools and Helper Functions for Other Code of J. Buttlar Version 0.7.2.9 Date 2015-05-20 Author Maintainer Collection of several

More information

Package TPD. June 14, 2018

Package TPD. June 14, 2018 Type Package Package TPD June 14, 2018 Title Methods for Measuring Functional Diversity Based on Trait Probability Density Version 1.0.0 Date 2018-06-13 Author Carlos P. Carmona

More information

Introduction to R. Adrienn Szabó. DMS Group, MTA SZTAKI. Aug 30, /62

Introduction to R. Adrienn Szabó. DMS Group, MTA SZTAKI. Aug 30, /62 Introduction to R Adrienn Szabó DMS Group, MTA SZTAKI Aug 30, 2014 1/62 1 What is R? What is R for? Who is R for? 2 Basics Data Structures Control Structures 3 ExtRa stuff R packages Unit testing in R

More information

Lecture 09: Feb 13, Data Oddities. Lists Coercion Special Values Missingness and NULL. James Balamuta STAT UIUC

Lecture 09: Feb 13, Data Oddities. Lists Coercion Special Values Missingness and NULL. James Balamuta STAT UIUC Lecture 09: Feb 13, 2019 Data Oddities Lists Coercion Special Values Missingness and NULL James Balamuta STAT 385 @ UIUC Announcements hw03 slated to be released on Thursday, Feb 14th, 2019 Due on Wednesday,

More information

A VERY BRIEF INTRODUCTION TO R

A VERY BRIEF INTRODUCTION TO R CS 432/532 INTRODUCTION TO WEB SCIENCE A VERY BRIEF INTRODUCTION TO R SCOTT G. AINSWORTH OLD DOMINION UNIVERSITY WHO AM I? Scott G. Ainsworth Former sailor Worked for several consulting firms Computer

More information

Package simulatorz. March 7, 2019

Package simulatorz. March 7, 2019 Type Package Package simulatorz March 7, 2019 Title Simulator for Collections of Independent Genomic Data Sets Version 1.16.0 Date 2014-08-03 Author Yuqing Zhang, Christoph Bernau, Levi Waldron Maintainer

More information

Package biomformat. April 11, 2018

Package biomformat. April 11, 2018 Version 1.7.0 Date 2016-04-16 Package biomformat April 11, 2018 Maintainer Paul J. McMurdie License GPL-2 Title An interface package for the BIOM file format Type Package Author

More information

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #43. Multidimensional Arrays

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #43. Multidimensional Arrays Introduction to Programming in C Department of Computer Science and Engineering Lecture No. #43 Multidimensional Arrays In this video will look at multi-dimensional arrays. (Refer Slide Time: 00:03) In

More information

Extremely short introduction to R Jean-Yves Sgro Feb 20, 2018

Extremely short introduction to R Jean-Yves Sgro Feb 20, 2018 Extremely short introduction to R Jean-Yves Sgro Feb 20, 2018 Contents 1 Suggested ahead activities 1 2 Introduction to R 2 2.1 Learning Objectives......................................... 2 3 Starting

More information

Risk Management Using R, SoSe 2013

Risk Management Using R, SoSe 2013 1. Problem (vectors and factors) a) Create a vector containing the numbers 1 to 10. In this vector, replace all numbers greater than 4 with 5. b) Create a sequence of length 5 starting at 0 with an increment

More information

MATH3880 Introduction to Statistics and DNA MATH5880 Statistics and DNA Practical Session Monday, 16 November pm BRAGG Cluster

MATH3880 Introduction to Statistics and DNA MATH5880 Statistics and DNA Practical Session Monday, 16 November pm BRAGG Cluster MATH3880 Introduction to Statistics and DNA MATH5880 Statistics and DNA Practical Session Monday, 6 November 2009 3.00 pm BRAGG Cluster This document contains the tasks need to be done and completed by

More information

Package filematrix. R topics documented: February 27, Type Package

Package filematrix. R topics documented: February 27, Type Package Type Package Package filematrix February 27, 2018 Title File-Backed Matrix Class with Convenient Read and Write Access Version 1.3 Date 2018-02-26 Description Interface for working with large matrices

More information

R:If, else and loops

R:If, else and loops R:If, else and loops Presenter: Georgiana Onicescu January 19, 2012 Presenter: Georgiana Onicescu R:ifelse,where,looping 1/ 17 Contents Vectors Matrices If else statements For loops Leaving the loop: stop,

More information

Stochastic Models. Introduction to R. Walt Pohl. February 28, Department of Business Administration

Stochastic Models. Introduction to R. Walt Pohl. February 28, Department of Business Administration Stochastic Models Introduction to R Walt Pohl Universität Zürich Department of Business Administration February 28, 2013 What is R? R is a freely-available general-purpose statistical package, developed

More information

seq(), seq_len(), min(), max(), length(), range(), any(), all() Comparison operators: <, <=, >, >=, ==,!= Logical operators: &&,,!

seq(), seq_len(), min(), max(), length(), range(), any(), all() Comparison operators: <, <=, >, >=, ==,!= Logical operators: &&,,! LECTURE 3: DATA STRUCTURES IN R (contd) STAT598z: Intro. to computing for statistics Vinayak Rao Department of Statistics, Purdue University SOME USEFUL R FUNCTIONS seq(), seq_len(), min(), max(), length(),

More information

R Tutorial. Anup Aprem September 13, 2016

R Tutorial. Anup Aprem September 13, 2016 R Tutorial Anup Aprem aaprem@ece.ubc.ca September 13, 2016 Installation Installing R: https://www.r-project.org/ Recommended to also install R Studio: https://www.rstudio.com/ Vectors Basic element is

More information

The Beginning g of an Introduction to R Dan Nettleton

The Beginning g of an Introduction to R Dan Nettleton The Beginning g of an Introduction to R for New Users 2010 Dan Nettleton 1 Preliminaries Throughout these slides, red text indicates text that is typed at the R prompt or text that is to be cut from a

More information

Package RankAggreg. May 15, 2018

Package RankAggreg. May 15, 2018 Type Package Title Weighted Rank Aggregation Version 0.6.5 Date 2018-05-14 Package RankAggreg May 15, 2018 Author Vasyl Pihur , Somnath Datta , Susmita Datta

More information

Finding Similar Sets. Applications Shingling Minhashing Locality-Sensitive Hashing

Finding Similar Sets. Applications Shingling Minhashing Locality-Sensitive Hashing Finding Similar Sets Applications Shingling Minhashing Locality-Sensitive Hashing Goals Many Web-mining problems can be expressed as finding similar sets:. Pages with similar words, e.g., for classification

More information

Package mimager. March 7, 2019

Package mimager. March 7, 2019 Package mimager March 7, 2019 Version 1.6.0 Type Package Title mimager: The Microarray Imager Easily visualize and inspect microarrays for spatial artifacts. License MIT + file LICENSE LazyData TRUE Depends

More information

Getting Started in R

Getting Started in R Getting Started in R Giles Hooker May 28, 2007 1 Overview R is a free alternative to Splus: a nice environment for data analysis and graphical exploration. It uses the objectoriented paradigm to implement

More information

Package glmmml. R topics documented: March 25, Encoding UTF-8 Version Date Title Generalized Linear Models with Clustering

Package glmmml. R topics documented: March 25, Encoding UTF-8 Version Date Title Generalized Linear Models with Clustering Encoding UTF-8 Version 1.0.3 Date 2018-03-25 Title Generalized Linear Models with Clustering Package glmmml March 25, 2018 Binomial and Poisson regression for clustered data, fixed and random effects with

More information

Explore a dataset with Shiny

Explore a dataset with Shiny BUILDING WEB APPLICATIONS IN R WITH SHINY: CASE STUDIES Explore a dataset with Shiny Dean Attali Shiny Consultant Explore a dataset with Shiny Dataset + Interactive environment + View data + Filter data

More information

STATISTICS WITH R PROGRAMMING Lecture Notes. Prepared by K.Rohini, Assistant Professor, CSE Department, GVPCEW.

STATISTICS WITH R PROGRAMMING Lecture Notes. Prepared by K.Rohini, Assistant Professor, CSE Department, GVPCEW. STATISTICS WITH R PROGRAMMING Lecture Notes Prepared by K.Rohini, Assistant Professor, CSE Department, GVPCEW. UNIT- I Introduction, How to run R, R Sessions and Functions, Basic Math, Variables, Data

More information

Package RMCriteria. April 13, 2018

Package RMCriteria. April 13, 2018 Type Package Title Multicriteria Package Version 0.1.0 Author Pedro Albuquerque and Gustavo Monteiro Package RMCriteria April 13, 2018 BugReports https://github.com/lamfo-unb/rmcriteria Maintainer Pedro

More information

Armstrong State University Engineering Studies MATLAB Marina 2D Arrays and Matrices Primer

Armstrong State University Engineering Studies MATLAB Marina 2D Arrays and Matrices Primer Armstrong State University Engineering Studies MATLAB Marina 2D Arrays and Matrices Primer Prerequisites The 2D Arrays and Matrices Primer assumes knowledge of the MATLAB IDE, MATLAB help, arithmetic operations,

More information

Discussion Notes 3 Stepwise Regression and Model Selection

Discussion Notes 3 Stepwise Regression and Model Selection Discussion Notes 3 Stepwise Regression and Model Selection Stepwise Regression There are many different commands for doing stepwise regression. Here we introduce the command step. There are many arguments

More information

Lecture 3: Basics of R Programming

Lecture 3: Basics of R Programming Lecture 3: Basics of R Programming This lecture introduces how to do things with R beyond simple commands. We will explore programming in R. What is programming? It is the act of instructing a computer

More information

Setting up Combined Sections

Setting up Combined Sections Setting up Combined Sections Combining Sections allows you to schedule more than one section of different classes in the same room, at the same time. This is most often done for cross-listed courses, but

More information

Package nima. May 23, 2018

Package nima. May 23, 2018 Title Nima Hejazi's R Toolbox Version 0.5.0 Package nima May 23, 2018 Miscellaneous R functions developed over the course of statistical research and scientific computing. These include, for example, utilities

More information

Package flsa. February 19, 2015

Package flsa. February 19, 2015 Type Package Package flsa February 19, 2015 Title Path algorithm for the general Fused Lasso Signal Approximator Version 1.05 Date 2013-03-23 Author Holger Hoefling Maintainer Holger Hoefling

More information

1 Statements and Expressions

1 Statements and Expressions ME 5241 Computer Aided Engineering Tom Chase Fall 2000 PSEUDO-CODE Pseudo-code is used to refine the logic of functions to its simplest possible form before writing the logic in any specific programming

More information

9. Elementary Algebraic and Transcendental Scalar Functions

9. Elementary Algebraic and Transcendental Scalar Functions Scalar Functions Summary. Introduction 2. Constants 2a. Numeric Constants 2b. Character Constants 2c. Symbol Constants 2d. Nested Constants 3. Scalar Functions 4. Arithmetic Scalar Functions 5. Operators

More information

LAB #2: SAMPLING, SAMPLING DISTRIBUTIONS, AND THE CLT

LAB #2: SAMPLING, SAMPLING DISTRIBUTIONS, AND THE CLT NAVAL POSTGRADUATE SCHOOL LAB #2: SAMPLING, SAMPLING DISTRIBUTIONS, AND THE CLT Statistics (OA3102) Lab #2: Sampling, Sampling Distributions, and the Central Limit Theorem Goal: Use R to demonstrate sampling

More information