Introduction to R: Data Types

Size: px
Start display at page:

Download "Introduction to R: Data Types"

Transcription

1 Introduction to R: Data Types Florian Geier September 26, 2018

2 Recapitulation

3 Possible workspaces Install R & RStudio on your laptop Use an RStudio server: Unibas members: if you plan to work with data stored on scicore, get a scicore account and start working on the scicore RStudio server FMI members: use the FMI RStudio server If none of these options are applicable, sign-up for a password and use a [temporary cloud service]

4 RStudio server for Unibas members: Connect to the university network via VPN Go to and login with your scicore username and password RStudio server for FMI members: Connect to the eduroam WLAN Login with where FMIuser is your FMIuser name; use the FMI password Start VPN (PulseSecure client, ask FMI-IT in case you don t have it) Go to and login with your FMIuser and password Temporary cloud service: Sign-up for a user name on the sheet Go to and login with your user name

5 Recommended work style RStudio preferences: General -> Save workspace to.rdata on exit: Never or Ask (Optional) General -> Restore previously open source documents at start-up: uncheck Directory settings: Create a course folder introductiontor For each lecture create a folder within the course folder, e.g. introductiontor/lecture2 Within this folder create an R script which harbors the code you write during the lecture Comment your code!

6 File system

7 Ask questions (online)! In between lectures you can ask questions under: Anyone can ask or answer questions related to the course topics

8 Data Types

9 integer logical array list numeric complex data.frame matrix vector character

10 What task do you want to solve? # add numbers 3/4 > pi/4 # compare numbers "hello world!" # print words

11 Logical Two possible values (TRUE or FALSE) Result of a logical expression x <- "foo" x==1 x!=1 ## [1] TRUE Take a look at R s logical operators with help(" ")

12 Function typeof() returns the data type, while is.logical() directly test if a data type is logical typeof(x == 3) ## [1] "logical" is.logical(na) ## [1] TRUE NA (not available, missing value) is a special logical value Don t use the short-cuts T and F for TRUE and FALSE

13 Numbers R offers different number types, among them: integer (natural numbers) numeric (real numbers; also called double in R) complex 12L ## [1] 12 typeof(12l) ## [1] "integer" 12 ## [1] 12 is.integer(12) ## [1] FALSE is.double(12) ## [1] TRUE

14 There are many arithmetic functions defined. Check the help pages to understand their functionallity, e.g. help.search("arithmetic Operators") or help.search("trigonometric"),?log2,?sd etc. sum(2,3,4) ## [1] 9 mean(2,3,4) # is it what you expect? ## [1] 2 Generally, comparison between numbers is tricky because of limited precision log(5/3) == log(5) - log(3) ## [1] FALSE

15 Special values: Inf, NaN, NULL NaN: if the result of a calculation is not a number sqrt(-1) ## Warning in sqrt(-1): NaNs produced ## [1] NaN Inf: infinity log(0) ## [1] -Inf NULL: often returned by expressions and functions whose value is undefined

16 Character A character (string) is either single ( ) or double (" ") quoted "Hello world!" ## [1] "Hello world!" Functions paste() or sprintf() can be used for combining/formatting numbers and characters and will be discussed later in the course

17 Coercion It is possible to transform one data type into another using the as.<data_type>() set of functions as.logical(0) # also try with any integer > 0 ## [1] FALSE as.numeric(true) ## [1] 1 as.integer("12.3") ## [1] 12 If needed atomic data types are automatically coerced to a more flexible type following the order: logical integer double character 1L/3L ## [1] sum(true,false,true) ## [1] 2

18 Vectors: R s basic data structure All basic data structures in R are implemented as vectors is.vector(3) ## [1] TRUE Vectors can be created in several ways, among are: combining elements with c() numerical sequences using : c("rice","milk","butter") ## [1] "rice" "milk" "butter" All elements of an (atomic) vector must be of the same type c("rice","milk",3) # automatic coercion ## [1] "rice" "milk" "3"

19 All arithmetic operations are applied element-wise x <- 1:8 x ## [1] length(x) ## [1] x/4 ## [1] y <- 1:3 x * y # warning: shorter vector is recycled! ## Warning in x * y: longer object length is not a multiple ## length ## [1]

20 Matrix A matrix is 2-dimensional: it has row and columns # matrix is filled column-wise by default: A <- matrix(1:12, nrow=3, ncol=4) A ## [,1] [,2] [,3] [,4] ## [1,] ## [2,] ## [3,] Can be converted to vectors using as.vector() as.vector(a) ## [1]

21 Two other helpful matrix constructors are rbind() and cbind() # row-wise binding: B <- rbind(c("cow","pig"), c("goat", "chicken")) B ## [,1] [,2] ## [1,] "cow" "pig" ## [2,] "goat" "chicken" # column-wise binding: C <- cbind(c("cow","pig"), c("goat", "chicken")) C ## [,1] [,2] ## [1,] "cow" "goat" ## [2,] "pig" "chicken"

22 By default * multiplies element-wise (with re-cycling) Use %*% for matrix-multiplication (or scalar product for vectors) # element-wise multiplication with re-cycling in column-ord x <- 1:4 A * x ## [,1] [,2] [,3] [,4] ## [1,] ## [2,] ## [3,] # matrix multiplication: A %*% x ## [,1] ## [1,] 70 ## [2,] 80 ## [3,] 90

23 Factor Factors are used to store categorical data The factor levels (categories) define the set of allowed values Factors are extensively used in the analysis of linear models

24 x <- c("head","tail","tail","head","tail") fx <- factor(x) fx ## [1] head tail tail head tail ## Levels: head tail levels(fx) ## [1] "head" "tail" typeof(fx) # internally represented as integer ## [1] "integer" as.integer(fx) ## [1]

25 Data frame R s excel sheet (only better!) and the most common way to store data Like a matrix its 2-dimensional, but each column can be of a different type D <- data.frame(person=c("mike", "Peter", "Jane"), degree=c("phd", "Msc", "Phd"), trained=c(t, F, T), Salary=c(76e3, 65e3, 77e3)) D ## Person degree trained Salary ## 1 Mike Phd TRUE ## 2 Peter Msc FALSE ## 3 Jane Phd TRUE 77000

26 A quick summary of the data types in a data frame is given by str() str(d) ## 'data.frame': 3 obs. of 4 variables: ## $ Person : Factor w/ 3 levels "Jane","Mike",..: ## $ degree : Factor w/ 2 levels "Msc","Phd": ## $ trained: logi TRUE FALSE TRUE ## $ Salary : num

27 On creation you can control the data type of each column explicitly: D <- data.frame(person=c("mike", "Peter", "Jane"), degree=factor(c("phd", "Msc", "Phd"), levels=c('bc','msc','phd')), trained=c(true, FALSE, TRUE), Salary=as.integer(c(76e3, 65e3, 77e3)), stringsasfactors=false) str(d) ## 'data.frame': 3 obs. of 4 variables: ## $ Person : chr "Mike" "Peter" "Jane" ## $ degree : Factor w/ 3 levels "Bc","Msc","Phd": ## $ trained: logi TRUE FALSE TRUE ## $ Salary : int Note the option stringsasfactors=false which turns-off the automatic conversion of character strings to factors.

28 How about accessing elements/rows/columns of a data.frame? This is the topic of the following lecture(s) As an outlook try D[1,] ## Person degree trained Salary ## 1 Mike Phd TRUE D[,'Person'] ## [1] "Mike" "Peter" "Jane" D[2,'trained'] ## [1] FALSE

29 List List is used as a general container in R Each element in the list can be of a different data type Lists are created with function list() BloodPressure <- rbind(systolic=c(134, 120, 129), diastolic=c(96, 80, 88)) data <- list(bloodpressure=bloodpressure, Patients=D)

30 Check the list structure with str() str(data) ## List of 2 ## $ BloodPressure: num [1:2, 1:3] ##..- attr(*, "dimnames")=list of 2 ##....$ : chr [1:2] "systolic" "diastolic" ##....$ : NULL ## $ Patients :'data.frame': 3 obs. of 4 variables: ##..$ Person : chr [1:3] "Mike" "Peter" "Jane" ##..$ degree : Factor w/ 3 levels "Bc","Msc","Phd": 3 2 ##..$ trained: logi [1:3] TRUE FALSE TRUE ##..$ Salary : int [1:3]

31 Summary Type Dimension Element Type Vector - all elements are of Matrix 2 the same type e.g. numeric, Array 2 character or logical Factor - elements come from a limited set of categories Data frame 2 R s excel sheet; each column is of one type List - container; every element can be of different type

32 Exercises Create a vector containing numbers 42 to 89. Create a vector containing the sequence 4.5 to 11.5 in steps of 0.5. Create a vector where the first 50 elements are TRUE the remaining 30 are FALSE. Create a vector of length 100 where every second element is FALSE. Hint: check the %% operator. Given the vector c(40,27,33,1,34,82), count how many values are larger then the average value. Hint: use type coercion and sum(). What is the result of 3/0? Compare with (3/0) * 0. Calculate all values for x {0, π/2, π} of the following expression: 16x(π x) y = 5π 2 4x(π x) Hint: pi is a pre-defined constant in R.

33 By flipping a coin you observe the following sequence of heads (H) and tails (T): H,H,H,T,T,H,T,T,H. What is a good data type in R to represent this data? Set up the following data frame: Symbol Chromosome Position Strand Etv3 chr Nfia chr Nipal3 chr Strada chr What type is each column? How can you control the data type when setting up the data frame?

34 R comes with many inbuild data sets. Among them are: iris - Edgar Anderson s Iris Data swiss - Swiss Fertility and Socioeconomic Indicators (1888) Data UScitiesD - Distances Between US Cities Check for each dataset what data types it contains! Also look at their help page e.g.?swiss.

Data types and structures

Data types and structures An introduc+on to Data types and structures Noémie Becker & Benedikt Holtmann Winter Semester 16/17 Course outline Day 3 Review GeFng started with R Crea+ng Objects Data types in R Data structures in R

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

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

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

Lecture 1: Getting Started and Data Basics

Lecture 1: Getting Started and Data Basics Lecture 1: Getting Started and Data Basics The first lecture is intended to provide you the basics for running R. Outline: 1. An Introductory R Session 2. R as a Calculator 3. Import, export and manipulate

More information

Text Mining with R: Building a Text Classifier

Text Mining with R: Building a Text Classifier Martin Schweinberger July 28, 2016 This post 1 will exemplify how to create a text classifier with R, i.e. it will implement a machine-learning algorithm, which classifies texts as being either a speech

More information

Variables: Objects in R

Variables: Objects in R Variables: Objects in R Basic R Functionality Introduction to R for Public Health Researchers Common new users frustations 1. Different versions of software 2. Data type problems (is that a string or a

More information

Why use R? Getting started. Why not use R? Introduction to R: It s hard to use at first. To perform inferential statistics (e.g., use a statistical

Why use R? Getting started. Why not use R? Introduction to R: It s hard to use at first. To perform inferential statistics (e.g., use a statistical Why use R? Introduction to R: Using R for statistics ti ti and data analysis BaRC Hot Topics November 2013 George W. Bell, Ph.D. http://jura.wi.mit.edu/bio/education/hot_topics/ To perform inferential

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

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

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

STAT 213: R/RStudio Intro

STAT 213: R/RStudio Intro STAT 213: R/RStudio Intro Colin Reimer Dawson Last Revised February 10, 2016 1 Starting R/RStudio Skip to the section below that is relevant to your choice of implementation. Installing R and RStudio Locally

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

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

Introduction to R: Using R for statistics and data analysis

Introduction to R: Using R for statistics and data analysis Why use R? Introduction to R: Using R for statistics and data analysis George W Bell, Ph.D. BaRC Hot Topics November 2014 Bioinformatics and Research Computing Whitehead Institute http://barc.wi.mit.edu/hot_topics/

More information

JavaScript Lecture 2

JavaScript Lecture 2 JavaScript Lecture 2 Waterford Institute of Technology May 5, 2016 John Fitzgerald Waterford Institute of Technology, JavaScriptLecture 2 1/28 JavaScript Introduction Topics discussed this presentation

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

Constraint-based Metabolic Reconstructions & Analysis H. Scott Hinton. Matlab Tutorial. Lesson: Matlab Tutorial

Constraint-based Metabolic Reconstructions & Analysis H. Scott Hinton. Matlab Tutorial. Lesson: Matlab Tutorial 1 Matlab Tutorial 2 Lecture Learning Objectives Each student should be able to: Describe the Matlab desktop Explain the basic use of Matlab variables Explain the basic use of Matlab scripts Explain the

More information

R: BASICS. Andrea Passarella. (plus some additions by Salvatore Ruggieri)

R: BASICS. Andrea Passarella. (plus some additions by Salvatore Ruggieri) R: BASICS Andrea Passarella (plus some additions by Salvatore Ruggieri) BASIC CONCEPTS R is an interpreted scripting language Types of interactions Console based Input commands into the console Examine

More information

STAT 113: R/RStudio Intro

STAT 113: R/RStudio Intro STAT 113: R/RStudio Intro Colin Reimer Dawson Last Revised September 1, 2017 1 Starting R/RStudio There are two ways you can run the software we will be using for labs, R and RStudio. Option 1 is to log

More information

Introduction to R: Using R for statistics and data analysis

Introduction to R: Using R for statistics and data analysis Why use R? Introduction to R: Using R for statistics and data analysis George W Bell, Ph.D. BaRC Hot Topics November 2015 Bioinformatics and Research Computing Whitehead Institute http://barc.wi.mit.edu/hot_topics/

More information

1. To answer this question, we will create 3 vectors named first, second, and third.

1. To answer this question, we will create 3 vectors named first, second, and third. 1. To answer this question, we will create 3 vectors named first, second, and third. (a) Create the vectors first, second, and third. Each vector should be made up of the following elements: first=(6,10,9,10,8,4,9,1,3,6),

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

MBV4410/9410 Fall Bioinformatics for Molecular Biology. Introduction to R

MBV4410/9410 Fall Bioinformatics for Molecular Biology. Introduction to R MBV4410/9410 Fall 2018 Bioinformatics for Molecular Biology Introduction to R Outline Introduce R Basic operations RStudio Bioconductor? Goal of the lecture Introduce you to R Show how to run R, basic

More information

ACHIEVEMENTS FROM TRAINING

ACHIEVEMENTS FROM TRAINING LEARN WELL TECHNOCRAFT DATA SCIENCE/ MACHINE LEARNING SYLLABUS 8TH YEAR OF ACCOMPLISHMENTS AUTHORIZED GLOBAL CERTIFICATION CENTER FOR MICROSOFT, ORACLE, IBM, AWS AND MANY MORE. 8411002339/7709292162 WWW.DW-LEARNWELL.COM

More information

Introduction to R and R-Studio Getting Data Into R. 1. Enter Data Directly into R...

Introduction to R and R-Studio Getting Data Into R. 1. Enter Data Directly into R... Introduction to R and R-Studio 2017-18 02. Getting Data Into R 1. Enter Data Directly into R...... 2. Import Excel Data (.xlsx ) into R..... 3. Import Stata Data (.dta ) into R...... a) From a folder on

More information

Introduction to MATLAB Programming

Introduction to MATLAB Programming Introduction to MATLAB Programming Arun A. Balakrishnan Asst. Professor Dept. of AE&I, RSET Overview 1 Overview 2 Introduction 3 Getting Started 4 Basics of Programming Overview 1 Overview 2 Introduction

More information

SISG/SISMID Module 3

SISG/SISMID Module 3 SISG/SISMID Module 3 Introduction to R Ken Rice Tim Thornton University of Washington Seattle, July 2018 Introduction: Course Aims This is a first course in R. We aim to cover; Reading in, summarizing

More information

Why use R? Getting started. Why not use R? Introduction to R: Log into tak. Start R R or. It s hard to use at first

Why use R? Getting started. Why not use R? Introduction to R: Log into tak. Start R R or. It s hard to use at first Why use R? Introduction to R: Using R for statistics ti ti and data analysis BaRC Hot Topics October 2011 George Bell, Ph.D. http://iona.wi.mit.edu/bio/education/r2011/ To perform inferential statistics

More information

Lab of COMP 406. MATLAB: Quick Start. Lab tutor : Gene Yu Zhao Mailbox: or Lab 1: 11th Sep, 2013

Lab of COMP 406. MATLAB: Quick Start. Lab tutor : Gene Yu Zhao Mailbox: or Lab 1: 11th Sep, 2013 Lab of COMP 406 MATLAB: Quick Start Lab tutor : Gene Yu Zhao Mailbox: csyuzhao@comp.polyu.edu.hk or genexinvivian@gmail.com Lab 1: 11th Sep, 2013 1 Where is Matlab? Find the Matlab under the folder 1.

More information

Starting Matlab. MATLAB Laboratory 09/09/10 Lecture. Command Window. Drives/Directories. Go to.

Starting Matlab. MATLAB Laboratory 09/09/10 Lecture. Command Window. Drives/Directories. Go to. Starting Matlab Go to MATLAB Laboratory 09/09/10 Lecture Lisa A. Oberbroeckling Loyola University Maryland loberbroeckling@loyola.edu http://ctx.loyola.edu and login with your Loyola name and password...

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

Basic R QMMA. Emanuele Taufer. 2/19/2018 Basic R (1)

Basic R QMMA. Emanuele Taufer. 2/19/2018 Basic R (1) Basic R QMMA Emanuele Taufer file:///c:/users/emanuele.taufer/google%20drive/2%20corsi/5%20qmma%20-%20mim/0%20classes/1-3_basic_r.html#(1) 1/21 Preliminary R is case sensitive: a is not the same as A.

More information

Introduction to MATLAB

Introduction to MATLAB Introduction to MATLAB Violeta Ivanova, Ph.D. Office for Educational Innovation & Technology violeta@mit.edu http://web.mit.edu/violeta/www Topics MATLAB Interface and Basics Calculus, Linear Algebra,

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

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

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

Introduction to R. Dataset Basics. March 2018

Introduction to R. Dataset Basics. March 2018 Introduction to R March 2018 1. Preliminaries.... a) Suggested packages for importing/exporting data.... b) FAQ: How to find the path of your dataset (or whatever). 2. Import/Export Data........ a) R (.Rdata)

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

Session 1 Nick Hathaway;

Session 1 Nick Hathaway; Session 1 Nick Hathaway; nicholas.hathaway@umassmed.edu Contents R Basics 1 Variables/objects.............................................. 1 Functions..................................................

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

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

cs61amt2_4 CS 61A Midterm #2 ver March 2, 1998 Exam version: A Your name login: cs61a- Discussion section number TA's name

cs61amt2_4 CS 61A Midterm #2 ver March 2, 1998 Exam version: A Your name login: cs61a- Discussion section number TA's name CS 61A Midterm #2 ver1.03 -- March 2, 1998 Exam version: A Your name login: cs61a- Discussion section number TA's name Look at the edge of your seat. Write your ROOM, seat row and number. Your row number

More information

cs1114 REVIEW of details test closed laptop period

cs1114 REVIEW of details test closed laptop period python details DOES NOT COVER FUNCTIONS!!! This is a sample of some of the things that you are responsible for do not believe that if you know only the things on this test that they will get an A on any

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

Advanced R Programming - Lecture 1

Advanced R Programming - Lecture 1 Advanced R Programming - Lecture 1 Krzysztof Bartoszek (slides by Leif Jonsson and Måns Magnusson) Linköping University krzysztof.bartoszek@liu.se 29 August 2017 1/ 43 Today 1 Aim of the course 2 3 4 5

More information

Data Classes. Introduction to R for Public Health Researchers

Data Classes. Introduction to R for Public Health Researchers Data Classes Introduction to R for Public Health Researchers Data Types: One dimensional types ( vectors ): - Character: strings or individual characters, quoted - Numeric: any real number(s) - Integer:

More information

R Course Lecture Notes

R Course Lecture Notes R Course Lecture Notes Marco Del Vecchio 1 1 marco.del.vecchio@outlook.com, www.marcodelvecchioblog.wordpress.com Acknowledgements Acknowledgements I would like to thank all the execs of the Warwick MORSE

More information

R Quick Start. Appendix A. A.1 Correspondences

R Quick Start. Appendix A. A.1 Correspondences Appendix A R Quick Start Here we present a quick introduction to the R data/statistical programming language. Further learning resources are listed at http://heather.cs.ucdavis.edu/~/matloff/r.html. R

More information

JavaScript: Coercion, Functions, Arrays

JavaScript: Coercion, Functions, Arrays JavaScript: Coercion, Functions, Arrays Computer Science and Engineering College of Engineering The Ohio State University Lecture 20 Conversion of Primitive Values String Number Boolean numbers 0 "0" false

More information

The SQLiteDF Package

The SQLiteDF Package The SQLiteDF Package August 25, 2006 Type Package Title Stores data frames & matrices in SQLite tables Version 0.1.18 Date 2006-08-18 Author Maintainer Transparently stores data frames

More information

Introduction to R Programming

Introduction to R Programming Course Overview Over the past few years, R has been steadily gaining popularity with business analysts, statisticians and data scientists as a tool of choice for conducting statistical analysis of data

More information

Course Layout. Go to https://www.license.boun.edu.tr, follow instr. Accessible within campus (only for the first download)

Course Layout. Go to https://www.license.boun.edu.tr, follow instr. Accessible within campus (only for the first download) Course Layout Lectures 1: Variables, Scripts and Operations 2: Visualization and Programming 3: Solving Equations, Fitting 4: Images, Animations, Advanced Methods 5: Optional: Symbolic Math, Simulink Course

More information

A Brief Introduction to R

A Brief Introduction to R A Brief Introduction to R Babak Shahbaba Department of Statistics, University of California, Irvine, USA Chapter 1 Introduction to R 1.1 Installing R To install R, follow these steps: 1. Go to http://www.r-project.org/.

More information

EP375 Computational Physics

EP375 Computational Physics EP375 Computational Physics Topic 1 MATLAB TUTORIAL BASICS Department of Engineering Physics University of Gaziantep Feb 2014 Sayfa 1 Basic Commands help command get help for a command clear all clears

More information

Using R for statistics and data analysis

Using R for statistics and data analysis Introduction ti to R: Using R for statistics and data analysis BaRC Hot Topics October 2011 George Bell, Ph.D. http://iona.wi.mit.edu/bio/education/r2011/ Why use R? To perform inferential statistics (e.g.,

More information

An introduction to R WS 2013/2014

An introduction to R WS 2013/2014 An introduction to R WS 2013/2014 Dr. Noémie Becker (AG Metzler) Dr. Sonja Grath (AG Parsch) Special thanks to: Dr. Martin Hutzenthaler (previously AG Metzler, now University of Frankfurt) course development,

More information

An Introductory Tutorial: Learning R for Quantitative Thinking in the Life Sciences. Scott C Merrill. September 5 th, 2012

An Introductory Tutorial: Learning R for Quantitative Thinking in the Life Sciences. Scott C Merrill. September 5 th, 2012 An Introductory Tutorial: Learning R for Quantitative Thinking in the Life Sciences Scott C Merrill September 5 th, 2012 Chapter 2 Additional help tools Last week you asked about getting help on packages.

More information

Recap From Last Time: Today s Learning Goals BIMM 143. Data analysis with R Lecture 4. Barry Grant.

Recap From Last Time: Today s Learning Goals BIMM 143. Data analysis with R Lecture 4. Barry Grant. BIMM 143 Data analysis with R Lecture 4 Barry Grant http://thegrantlab.org/bimm143 Recap From Last Time: Substitution matrices: Where our alignment match and mis-match scores typically come from Comparing

More information

Numeric Vectors STAT 133. Gaston Sanchez. Department of Statistics, UC Berkeley

Numeric Vectors STAT 133. Gaston Sanchez. Department of Statistics, UC Berkeley Numeric Vectors 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

R Notebook Introduction to R in Immunobiology course

R Notebook Introduction to R in Immunobiology course R Notebook Introduction to R in Immunobiology course This is the R file I used to go through the introduction to R. I hope it will help you to understand things better. We will also use the presenters

More information

Introduction to R. UCLA Statistical Consulting Center R Bootcamp. Irina Kukuyeva September 20, 2010

Introduction to R. UCLA Statistical Consulting Center R Bootcamp. Irina Kukuyeva September 20, 2010 UCLA Statistical Consulting Center R Bootcamp Irina Kukuyeva ikukuyeva@stat.ucla.edu September 20, 2010 Outline 1 Introduction 2 Preliminaries 3 Working with Vectors and Matrices 4 Data Sets in R 5 Overview

More information

Python lab session 1

Python lab session 1 Python lab session 1 Dr Ben Dudson, Department of Physics, University of York 28th January 2011 Python labs Before we can start using Python, first make sure: ˆ You can log into a computer using your username

More information

Brief cheat sheet of major functions covered here. shoe<-c(8,7,8.5,6,10.5,11,7,6,12,10)

Brief cheat sheet of major functions covered here. shoe<-c(8,7,8.5,6,10.5,11,7,6,12,10) 1 Class 2. Handling data in R Creating, editing, reading, & exporting data frames; sorting, subsetting, combining Goals: (1) Creating matrices and dataframes: cbind and as.data.frame (2) Editing data:

More information

Statistics for Biologists: Practicals

Statistics for Biologists: Practicals Statistics for Biologists: Practicals Peter Stoll University of Basel HS 2012 Peter Stoll (University of Basel) Statistics for Biologists: Practicals HS 2012 1 / 22 Outline Getting started Essentials of

More information

MBI REU Matlab Tutorial

MBI REU Matlab Tutorial MBI REU Matlab Tutorial Lecturer: Reginald L. McGee II, Ph.D. June 8, 2017 MATLAB MATrix LABoratory MATLAB is a tool for numerical computation and visualization which allows Real & Complex Arithmetics

More information

Certified LabVIEW Associate Developer Exam. Test Booklet

Certified LabVIEW Associate Developer Exam. Test Booklet Certified LabVIEW Associate Developer Exam Test Booklet Instructions: If you did not receive this exam in a sealed envelope stamped "NI Certification," DO NOT ACCEPT this exam. Return it to the proctor

More information

CS 61A Midterm #2 ver March 2, 1998 Exam version: A. Your name. login: cs61a- Discussion section number. TA's name

CS 61A Midterm #2 ver March 2, 1998 Exam version: A. Your name. login: cs61a- Discussion section number. TA's name CS 61A Midterm #2 ver1.03 -- March 2, 1998 Exam version: A Your name login: cs61a- Discussion section number TA's name Look at the edge of your seat. Write your ROOM, seat row and number. Your row number

More information

Dr Richard Greenaway

Dr Richard Greenaway SCHOOL OF PHYSICS, ASTRONOMY & MATHEMATICS 4PAM1008 MATLAB 3 Creating, Organising & Processing Data Dr Richard Greenaway 3 Creating, Organising & Processing Data In this Workshop the matrix type is introduced

More information

Introduction to 3/15/2012. Poll Are You Sticking Around for Part 2? 1. Yes 2. No. Steve Berman, FCAS, MAAA Jim Guszcza, FCAS, MAAA

Introduction to 3/15/2012. Poll Are You Sticking Around for Part 2? 1. Yes 2. No. Steve Berman, FCAS, MAAA Jim Guszcza, FCAS, MAAA Introduction to CAS RPM Seminar March 19, 2012 Steve Berman, FCAS, MAAA Jim Guszcza, FCAS, MAAA Poll Are You Sticking Around for Part 2? 1. Yes 2. No 1 1 Poll How Much Do You Know About R? 1. Isn t that

More information

Administrivia. Simple data types

Administrivia. Simple data types Administrivia Lists, higher order procedures, and symbols 6.037 - Structure and Interpretation of Computer Programs Mike Phillips (mpp) Massachusetts Institute of Technology Project 0 was due today Reminder:

More information

5. Using the precendence rules for arithmetic operators, determine which statement is true.

5. Using the precendence rules for arithmetic operators, determine which statement is true. 1. Which statement assigns the value 3 to the variable mynum and prints the value of mynum to the command window? (a) mynum == 2 + 1; (b) mynum = 2 + 1; (c) mynum == 3 (d) mynum = 2 + 1 (e) mynum = 3;

More information

6.094 Introduction to MATLAB January (IAP) 2009

6.094 Introduction to MATLAB January (IAP) 2009 MIT OpenCourseWare http://ocw.mit.edu 6.094 Introduction to MATLAB January (IAP) 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. 6.094 Introduction

More information

MATLAB Basics. Configure a MATLAB Package 6/7/2017. Stanley Liang, PhD York University. Get a MATLAB Student License on Matworks

MATLAB Basics. Configure a MATLAB Package 6/7/2017. Stanley Liang, PhD York University. Get a MATLAB Student License on Matworks MATLAB Basics Stanley Liang, PhD York University Configure a MATLAB Package Get a MATLAB Student License on Matworks Visit MathWorks at https://www.mathworks.com/ It is recommended signing up with a student

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

Python Programming Exercises 1

Python Programming Exercises 1 Python Programming Exercises 1 Notes: throughout these exercises >>> preceeds code that should be typed directly into the Python interpreter. To get the most out of these exercises, don t just follow them

More information

Data Structures in R. Tony Yao-Jen Kuo

Data Structures in R. Tony Yao-Jen Kuo Data Structures in R Tony Yao-Jen Kuo An overview Data structures... collects scalars Data structures... collects scalars can be indexing Data structures... collects scalars can be indexing can be slicing

More information

getting started in R

getting started in R Garrick Aden-Buie // Friday, March 25, 2016 getting started in R 1 / 70 getting started in R Garrick Aden-Buie // Friday, March 25, 2016 INFORMS Code & Data Boot Camp Today we ll talk about Garrick Aden-Buie

More information

R Short Course Session 1

R Short Course Session 1 R Short Course Session 1 Daniel Zhao, PhD Sixia Chen, PhD Department of Biostatistics and Epidemiology College of Public Health, OUHSC 10/23/2015 Outline Overview of the 5 sessions Pre-requisite requirements

More information

Vector: A series of scalars contained in a column or row. Dimensions: How many rows and columns a vector or matrix has.

Vector: A series of scalars contained in a column or row. Dimensions: How many rows and columns a vector or matrix has. ASSIGNMENT 0 Introduction to Linear Algebra (Basics of vectors and matrices) Due 3:30 PM, Tuesday, October 10 th. Assignments should be submitted via e-mail to: matlabfun.ucsd@gmail.com You can also submit

More information

R Basics / Course Business

R Basics / Course Business R Basics / Course Business We ll be using a sample dataset in class today: CourseWeb: Course Documents " Sample Data " Week 2 Can download to your computer before class CourseWeb survey on research/stats

More information

Getting Started with ORE - 1

Getting Started with ORE - 1 Hello, and welcome to this online, self-paced lesson entitled Getting Started with ORE. This session is part of an eight-lesson tutorial series on Oracle R Enterprise. My name is Brian Pottle. I will be

More information

MATLAB: The Basics. Dmitry Adamskiy 9 November 2011

MATLAB: The Basics. Dmitry Adamskiy 9 November 2011 MATLAB: The Basics Dmitry Adamskiy adamskiy@cs.rhul.ac.uk 9 November 2011 1 Starting Up MATLAB Windows users: Start up MATLAB by double clicking on the MATLAB icon. Unix/Linux users: Start up by typing

More information

Calling Ox from Excel

Calling Ox from Excel Calling Ox from Excel Jurgen A. Doornik December 12, 2018 Contents 1 The excel2ox Ox package................................... 1 1.1 Version....................................... 1 1.2 XLL.........................................

More information

Perl for Biologists. Session 2 March 19, Constants, variables and functions. Jaroslaw Pillardy

Perl for Biologists. Session 2 March 19, Constants, variables and functions. Jaroslaw Pillardy Perl for Biologists Session 2 March 19, 2014 Constants, variables and functions Jaroslaw Pillardy Session 2: Constants, variables and functions Perl for Biologists 1.1 1 "shebang" notation path to the

More information

Intro to R. Fall Fall 2017 CS130 - Intro to R 1

Intro to R. Fall Fall 2017 CS130 - Intro to R 1 Intro to R Fall 2017 Fall 2017 CS130 - Intro to R 1 Intro to R R is a language and environment that allows: Data management Graphs and tables Statistical analyses You will need: some basic statistics We

More information

Stat 302 Statistical Software and Its Applications Introduction to R

Stat 302 Statistical Software and Its Applications Introduction to R Stat 302 Statistical Software and Its Applications Introduction to R Yen-Chi Chen Department of Statistics, University of Washington Autumn 2016 1 / 23 Statistical Software There are many, many statistical

More information

Lab 1: Getting started with R and RStudio Questions? or

Lab 1: Getting started with R and RStudio Questions? or Lab 1: Getting started with R and RStudio Questions? david.montwe@ualberta.ca or isaacren@ualberta.ca 1. Installing R and RStudio To install R, go to https://cran.r-project.org/ and click on the Download

More information

Chapter 1 Introduction to MATLAB

Chapter 1 Introduction to MATLAB Chapter 1 Introduction to MATLAB 1.1 What is MATLAB? MATLAB = MATrix LABoratory, the language of technical computing, modeling and simulation, data analysis and processing, visualization and graphics,

More information

An Introduction to R- Programming

An Introduction to R- Programming An Introduction to R- Programming Hadeel Alkofide, Msc, PhD NOT a biostatistician or R expert just simply an R user Some slides were adapted from lectures by Angie Mae Rodday MSc, PhD at Tufts University

More information

CS 1110 SPRING 2016: GETTING STARTED (Jan 27-28) First Name: Last Name: NetID:

CS 1110 SPRING 2016: GETTING STARTED (Jan 27-28)   First Name: Last Name: NetID: CS 1110 SPRING 2016: GETTING STARTED (Jan 27-28) http://www.cs.cornell.edu/courses/cs1110/2016sp/labs/lab01/lab01.pdf First Name: Last Name: NetID: Goals. Learning a computer language is a lot like learning

More information

Computer Science E-119 Fall Problem Set 1. Due before lecture on Wednesday, September 26

Computer Science E-119 Fall Problem Set 1. Due before lecture on Wednesday, September 26 Due before lecture on Wednesday, September 26 Getting Started Before starting this assignment, make sure that you have completed Problem Set 0, which can be found on the assignments page of the course

More information

file:///users/williams03/a/workshops/2015.march/final/intro_to_r.html

file:///users/williams03/a/workshops/2015.march/final/intro_to_r.html Intro to R R is a functional programming language, which means that most of what one does is apply functions to objects. We will begin with a brief introduction to R objects and how functions work, and

More information

2nd Introduction to the Matrix package

2nd Introduction to the Matrix package 2nd Introduction to the Matrix package Martin Maechler and Douglas Bates R Core Development Team maechler@stat.math.ethz.ch, bates@r-project.org September 2006 (typeset on October 7, 2007) Abstract Linear

More information

Mails : ; Document version: 14/09/12

Mails : ; Document version: 14/09/12 Mails : leslie.regad@univ-paris-diderot.fr ; gaelle.lelandais@univ-paris-diderot.fr Document version: 14/09/12 A freely available language and environment Statistical computing Graphics Supplementary

More information

Introduction to MATLAB. Simon O Keefe Non-Standard Computation Group

Introduction to MATLAB. Simon O Keefe Non-Standard Computation Group Introduction to MATLAB Simon O Keefe Non-Standard Computation Group sok@cs.york.ac.uk Content n An introduction to MATLAB n The MATLAB interfaces n Variables, vectors and matrices n Using operators n Using

More information

MAT 3271: Selected Solutions to the Assignment 6

MAT 3271: Selected Solutions to the Assignment 6 Chapter 2: Major Exercises MAT 3271: Selected Solutions to the Assignment 6 1. Since a projective plan is a model of incidence geometry, Incidence Axioms 1-3 and Propositions 2.1-2.5 (which follow logically

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

Getting started with MATLAB

Getting started with MATLAB Getting started with MATLAB You can work through this tutorial in the computer classes over the first 2 weeks, or in your own time. The Farber and Goldfarb computer classrooms have working Matlab, but

More information

Package tester. R topics documented: February 20, 2015

Package tester. R topics documented: February 20, 2015 Type Package Title Tests and checks characteristics of R objects Version 0.1.7 Date 2013-11-14 Author Gaston Sanchez Package tester February 20, 2015 Maintainer Gaston Sanchez tester

More information