Extremely short introduction to R Jean-Yves Sgro Feb 20, 2018
|
|
- Meredith Osborne
- 5 years ago
- Views:
Transcription
1 Extremely short introduction to R Jean-Yves Sgro Feb 20, 2018 Contents 1 Suggested ahead activities 1 2 Introduction to R Learning Objectives Starting R 2 4 R objects and variable assignment Data types Built-in functions list: ls() class() combine: c() length() Getting help 5 7 Vectorisation 5 8 More complex data Vector Matrix Dataframes Dataframe manipulation Generating data Regular sequences Repeat and sequence functions: Levels: gl() and expand.grid() Random numbers Simple graphics with plot() 11 1 Suggested ahead activities The following is a very succinct introduction to aspects of the software R that we ll explore in lab exercises. If you want to learn more ahead of time before class you could do the following fun activity: 1
2 What Description link Interactive Try R short course. There are 7 chapters rewarding you with a badge for each complete chapter. No software installation required, only a web browser. tryr.codeschool.com 2 Introduction to R 2.1 Learning Objectives Run R understand R objects understand objects data structure generate data learn basic plotting methods Acknowledgments: loosely based on R Tutorial by Chi Yau 1 3 Starting R R can be accessed by double-clicking on the R icon, or within a Terminal by simply typing the letter R at the prompt. TASK Do one of the following:. Find the R icon in the /Applications directory Find Terminal in /Applications/Utilities (or use the top-right icon that looks like a magnifying glass - Sportlight Search and type the word Terminal. If you are using the terminal type R at the $ prompt: R A splash screen will be typed on the terminal. The welcome screen will list the current version being run and will await further commands after the R prompt > R version ( ) -- "Single Candle" Copyright (C) 2017 The R Foundation for Statistical Computing Platform: x86_64-apple-darwin (64-bit) 1 2
3 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > TASK At the bottom the R prompt > invites the user to type commands. At this point R can be used as a calculator by performing simple arithmetic functions. Type within your R console:. For example: [1] 4 sqrt(2) [1] pi [1] Note: [1] at the beginning is the line number. In more complex situations each line would be numbered. 4 R objects and variable assignment In every computer language variables provide a means of accessing the data stored in memory. R does not provide direct access to the computer s memory but rather provides a number of specialized data structures we will refer to as objects. These objects are referred to through symbols or variables. 2 Assigning alues to variables can be accomplished with the assignment operators = or <-. For data containing characters the assignment should be within quotes. We ll see later the different types of data available. Note that nothing happens when the assignment occurs: TASK Try it as we go
4 x = 1 w ="word" However, simply typing the variable name at the prompt will print out its value: x [1] 1 w [1] "word" The name of an object must start with a letter (A Z or a z) but can include letters, digits (0 9), dots (.), and underscores ( _ ). R case sensitive and discriminates between uppercase and lowercase letters in the names of the objects, so that a and A can name two distinct objects (even under Windows). 4.1 Data types As we just saw, characters have to be placed within quotes. The following data types occur often with routine R calculations: Numeric Integer Complex Logical Character 5 Built-in functions R functions are invoked by its name, then followed by parenthesis. Parenthesis contain mandatory or optional arguments to pass to the function. Parenthesis are always written even if they remain empty. 5.1 list: ls() For example we can now list the R objects that we created above with the function ls(): ls() [1] "w" "x" 5.2 class() We can verify the type, or class of these variables with the function class() class(x) [1] "numeric" 4
5 class(w) [1] "character" 5.3 combine: c() The combine function is essential in R. For example the follwing three numeric values are combined into a vector. c(1, 2, 3) [1] Since we did not assign to a variable the output is immediately printed. Here is the same vector assigned to variable v v <- c(1, 2, 3) This time no out put is produced but the data is stored in memory and can be called again. 5.4 length() It may be useful to know the length of an object: length(v) [1] 3 6 Getting help R provides extensive documentation. Depending on the installation method or how you access R the results appear either in plain text within the R console, an HTML page etc. For example, entering?c or help(c) at the prompt gives documentation of the function c() in R. TASK EXERCISE Try a help command on at least one of the function we have seen. Note: in help,... often means that arguments can be passed along by other funtions 7 Vectorisation R calculations are vectorized in the sense that any calculation can be applied to all elements of e.g. a vector. For example: # multiply elements of vector v by 10: v * 10 [1] # divide elements of vector v by 2: v / 2 [1]
6 Note that the character # can be used as a way to comment the text. This is useful when saving all the commands into a text script, so that the future you or anyone else trying your code should understand the intention of the calculation(s.) 8 More complex data There exists other types of more complex data that R can handle, most of them can be tabular or multidimensional: Vector Matrix List Data Frame 8.1 Vector We already created a one-dimensional vector v above containing numeric values. But vectors can also contain characters or logical data. However, all data in one vector has to be of the same nature. # create a vector of character vc <- c("a", "b","c") 8.2 Matrix A matrix is a collection of data elements arranged in a two-dimensional rectangular layout. All elements have to be of the same nature, e.g. numeric or character. The function matrix() can be used to create a new matrix object. matrix(c(1,2,3,4,5,6), nrow=2) [,1] [,2] [,3] [1,] [2,] However, some more information needs to be given, for example how many rows should the matrix have, this is done by the nrow= option. Obviously the number of elements given should be in the number of expected row by columns. The default values are nrow = 1, ncol = 1 and the default filling method is by column since the default is byrow = FALSE. TASK EXERCISE Try to change some of the defaults. For example change byrow = FALSE to byrow = TRUE. Your results: 6
7 8.2.1 Combining vectors to create a matrix Another way to create a matrix is combining vectors of the same length with the functions cbind() or rbind() to combine by colum or row. TASK EXERCISE Try these commands on the vectors v and vc - for example: # with v cvv <- cbind(v,v) rvv <- rbind(v,v) cvvvc <- cbind(v,v,v) # with character vector vc vc2 <- cbind(vc,vc) # with both v and vc vc3 <- cbind(v,vc) Your results: What happened when using both v and vc (hint: class(), quotes) 9 Dataframes Dataframes are a type of table that allows each column to be of a different variable type. For example one column can be characters and another column can be numbers. We can construct a dataframe starting with vectors with the function data.frame() # num: a vector if numbers num <- c(2, 3, 5) # let: a vector or letters let <- c("aa", "bb", "cc") # tf: a vector or logicals true or false tf <- c(true, FALSE, TRUE) 7
8 # df is a data frame df = data.frame(num, let, tf) We can inquire about df: the class of the object, its dimensions, the name of the headers for the columns, class(df) [1] "data.frame" dim(df) [1] 3 3 names(df) [1] "num" "let" "tf" 9.1 Dataframe manipulation As just as simple demonstration we ll change the name of the rows. For now the dataframe looks like this: df num let tf 1 2 aa TRUE 2 3 bb FALSE 3 5 cc TRUE and if we ask the name of each row we get the current list: rownames(df) [1] "1" "2" "3" In R things can change by reassigning new values, so we can indeed change the row names with the function**rownames() and giving new values. For example: row.names(df) <- c("row1", "row2", "row3") # print df df num let tf row1 2 aa TRUE row2 3 bb FALSE row3 5 cc TRUE In the same way we could change the column names: colnames(df) <- c("numbers", "letters", "logical") Note: functions row.names and rownames exist for rows, but only colnames exist for columns. In this final version the data itself is not altered but we changed both the column and row names: df numbers letters logical row1 2 aa TRUE row2 3 bb FALSE row3 5 cc TRUE 8
9 10 Generating data There are many ways to generate data from within R as series of numbers, in sequence or as random numbers. This section is purposefully kept simple Regular sequences The generation of numbers in sequence can be useful to create lists. The following command will generate an object with 10 elements; a regular sequence of integers ranging from 1 to 10, saved wihtin variable x thanks to the operator : x <- 1:10 x [1] Various options can be used to alter the results, for example requesting 11 values, starting with 3 and ending at 5. seq(length=11, from=3, to=5) [1] Repeat and sequence functions: It may be useful to print a number multiple time. This can be done with the rep() function. For example: rep(1,15) [1] The function sequence() creates a series of sequences of integers each ending by the numbers given as arguments (** separators added for clarity). sequence(2:5) [1] 1 2 *1 2 3* * * To understand this output it is useful to also remember that 2:5 means 2, 3, 4, 5 and that the function will apply to each of these digits in turn Levels: gl() and expand.grid() These two functions are very useful for creating tables containing experimental data. The function gl() generates levels series of factors or categories as values or labels. The following example will generate 4 each of 2 levels: gl(2, 4, labels = c("control", "Treat")) [1] Control Control Control Control Treat Treat Treat Treat Levels: Control Treat The functionexpand.grid() creates a data frame with all possible combinations of vectors or factors given as arguments. This example 9
10 expand.grid(h=c(60,80), w=c(100, 300), sex=c("male", "Female")) h w sex Male Male Male Male Female Female Female Female Note: The arguments are rotated as a function of their position in the command Try the following: expand.grid(sex=c("male", "Female"), h=c(60,80), w=c(100, 300)) How many lines is the table (not counting the header? (hint: row numbers) The use of seq() can also be useful in this context. Try the following examples: expand.grid(height = seq(3, 3, 5), weight = seq(100, 250, 50), sex = c("male","female")) How many lines is the table (not counting the header? (hint: row numbers) Add one more variable treatment = c("control", "drug")) and see how much the table explands: expand.grid(height = seq(3, 3, 5), weight = seq(100, 250, 50), sex = c("male","female")) How many lines is the table (not counting the header? (hint: row numbers) Note: the function dim() can be applied directly as well, for example: dim(expand.grid(sex=c("male", "Female"), h=c(60,80), w=c(100, 300))) 10.4 Random numbers Most of the statistical functions are available within R such as Gaussian (Normal), Poisson, Student t-test etc. To generate random numbers, the function based on the Normal distribution we use the function rnorm() (r for random and norm for Normal.) The number of desired random numbers is given as argument. Since these are random, the answers are never the same! TASK Perform the following command requesting a single random number a few times (e.g. 5 times) in a row: rnorm(1) Do you get the same result every time? [ ] Yes [ ] No 10
11 To provide means of reproducible the function set.seed() can be used to obtain the same result every time. The seed is a number chosen by the author. Here is an example selecting three numbers. set.seed(33); rnorm(3) [1] set.seed(33); rnorm(3) [1] set.seed(33); rnorm(3) [1] However, changing the seed value will change the results: set.seed(22); rnorm(3) [1] Important note 3 [these] Pseudo Random Number Generators because they are in fact fully algorithmic: given the same seed, you get the same sequence. And that is a feature and not a bug. One R method for choosing letters at random is with the function sample(). The term LETTERS represents the alphabet and is built-in. sample(letters, 5) [1] "P" "S" "K" "I" "V" sample(letters, 5) [1] "P" "L" "U" "K" "B" In the same way as before seeting a seed will reproduce the same result every time. set.seed(42); sample(letters, 5) [1] "X" "Z" "G" "T" "O" set.seed(42); sample(letters, 5) [1] "X" "Z" "G" "T" "O" 11 Simple graphics with plot() We will create a very simple graphic output from generated random numbers: Create a data vector of 100 random numbers (note: if you choose the same seed number your final plot will be identical.) set.seed(9) data <- rnorm(100) The plot() function will create a simple scatter plot with circles as the default symbol. plot(data)
12 data Index Figure 1: default two-dimensional plot. It is possible to include more than one plot on the same figure/page with the parameter function modifying the number of rows and columns planned for plotting: par(mfrow=c(1,1)) by default. As a brief example we ll replot these data points as points, lines, both, and overlay. The labels for the axes are rendered blank to make the final layout less cluttered. par(mfrow = c(2,2)) plot(data, type = "p", main = "points", ylab = "", xlab = "") plot(data, type = "l", main = "lines", ylab = "", xlab = "") plot(data, type = "b", main = "both", ylab = "", xlab = "") plot(data, type = "o", main = "both overplot", ylab = "", xlab = "") points lines both both overplot Figure 2: split screen plots. It is useful to reset the number of images or plots to 1: par(mfrow = c(1,1)) 12
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 informationR: 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 informationData 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 informationA (very) brief introduction to R
A (very) brief introduction to R You typically start R at the command line prompt in a command line interface (CLI) mode. It is not a graphical user interface (GUI) although there are some efforts to produce
More informationSTA 250: Statistics Lab 1
STA 250: Statistics Lab 1 This lab work is intended to be an introduction to the software R. What follows is a description of the basic functionalities of R, along with a series of tasks that ou d have
More informationIntroduction to R 21/11/2016
Introduction to R 21/11/2016 C3BI Vincent Guillemot & Anne Biton R: presentation and installation Where? https://cran.r-project.org/ How to install and use it? Follow the steps: you don t need advanced
More informationGetting Started with R
Getting Started with R STAT 133 Gaston Sanchez Department of Statistics, UC Berkeley gastonsanchez.com github.com/gastonstat/stat133 Course web: gastonsanchez.com/stat133 Tool Some of you may have used
More informationMails : ; 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 informationStatistical Data Analysis: R Tutorial
1 August 29, 2012 Statistical Data Analysis: R Tutorial Dr A. J. Bevan, Contents 1 Getting started 1 2 Basic calculations 2 3 More advanced calulations 3 4 Plotting data 4 5 The quantmod package 5 1 Getting
More informationThe Very Basics of the R Interpreter
Chapter 2 The Very Basics of the R Interpreter OK, the computer is fired up. We have R installed. It is time to get started. 1. Start R by double-clicking on the R desktop icon. 2. Alternatively, open
More informationITS 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 informationMatrix 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 informationIntroduction 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 informationGetting started with simulating data in R: some helpful functions and how to use them Ariel Muldoon August 28, 2018
Getting started with simulating data in R: some helpful functions and how to use them Ariel Muldoon August 28, 2018 Contents Overview 2 Generating random numbers 2 rnorm() to generate random numbers from
More informationlimma: A brief introduction to R
limma: A brief introduction to R Natalie P. Thorne September 5, 2006 R basics i R is a command line driven environment. This means you have to type in commands (line-by-line) for it to compute or calculate
More informationLecture 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 informationThis document is designed to get you started with using R
An Introduction to R This document is designed to get you started with using R We will learn about what R is and its advantages over other statistics packages the basics of R plotting data and graphs What
More informationR version ( ) Copyright (C) 2009 The R Foundation for Statistical Computing ISBN
Math 3070 1. Treibergs County Data: Histograms with variable Class Widths. Name: Example June 1, 2011 Data File Used in this Analysis: # Math 3070-1 County populations Treibergs # # Source: C Goodall,
More informationA 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 information1 Introduction to Matlab
1 Introduction to Matlab 1. What is Matlab? Matlab is a computer program designed to do mathematics. You might think of it as a super-calculator. That is, once Matlab has been started, you can enter computations,
More informationII.Matrix. Creates matrix, takes a vector argument and turns it into a matrix matrix(data, nrow, ncol, byrow = F)
II.Matrix A matrix is a two dimensional array, it consists of elements of the same type and displayed in rectangular form. The first index denotes the row; the second index denotes the column of the specified
More informationIntroduction to MATLAB
Chapter 1 Introduction to MATLAB 1.1 Software Philosophy Matrix-based numeric computation MATrix LABoratory built-in support for standard matrix and vector operations High-level programming language Programming
More informationDescription/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 informationApplied Calculus. Lab 1: An Introduction to R
1 Math 131/135/194, Fall 2004 Applied Calculus Profs. Kaplan & Flath Macalester College Lab 1: An Introduction to R Goal of this lab To begin to see how to use R. What is R? R is a computer package for
More informationFunctions 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 informationVariables: 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 informationBasic Unix. Set-up. Finding Terminal on the imac. Method 1. Biochemistry laboratories Jean-Yves Sgro
Basic Unix Biochemistry laboratories - 201 Jean-Yves Sgro -jsgro@wisc.edu Find this document here (short URL) today: http://go.wisc.edu/4iu8u5 *Note*: To see as slides click on **"Gift icon"** at the top
More informationD-Optimal Designs. Chapter 888. Introduction. D-Optimal Design Overview
Chapter 888 Introduction This procedure generates D-optimal designs for multi-factor experiments with both quantitative and qualitative factors. The factors can have a mixed number of levels. For example,
More informationReading 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 informationSML 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 informationTopics for today Input / Output Using data frames Mathematics with vectors and matrices Summary statistics Basic graphics
Topics for today Input / Output Using data frames Mathematics with vectors and matrices Summary statistics Basic graphics Introduction to S-Plus 1 Input: Data files For rectangular data files (n rows,
More informationBasic 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 informationAdvanced Econometric Methods EMET3011/8014
Advanced Econometric Methods EMET3011/8014 Lecture 2 John Stachurski Semester 1, 2011 Announcements Missed first lecture? See www.johnstachurski.net/emet Weekly download of course notes First computer
More informationIntroduction 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 informationPractice for Learning R and Learning Latex
Practice for Learning R and Learning Latex Jennifer Pan August, 2011 Latex Environments A) Try to create the following equations: 1. 5+6 α = β2 2. P r( 1.96 Z 1.96) = 0.95 ( ) ( ) sy 1 r 2 3. ˆβx = r xy
More informationSTAT 540 Computing in Statistics
STAT 540 Computing in Statistics Introduces programming skills in two important statistical computer languages/packages. 30-40% R and 60-70% SAS Examples of Programming Skills: 1. Importing Data from External
More informationStat 290: Lab 2. Introduction to R/S-Plus
Stat 290: Lab 2 Introduction to R/S-Plus Lab Objectives 1. To introduce basic R/S commands 2. Exploratory Data Tools Assignment Work through the example on your own and fill in numerical answers and graphs.
More informationLab 1 Introduction to R
Lab 1 Introduction to R Date: August 23, 2011 Assignment and Report Due Date: August 30, 2011 Goal: The purpose of this lab is to get R running on your machines and to get you familiar with the basics
More informationUTORid: 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 informationEPIB Four Lecture Overview of R
EPIB-613 - Four Lecture Overview of R R is a package with enormous capacity for complex statistical analysis. We will see only a small proportion of what it can do. The R component of EPIB-613 is divided
More informationS Basics. Statistics 135. Autumn Copyright c 2005 by Mark E. Irwin
S Basics Statistics 135 Autumn 2005 Copyright c 2005 by Mark E. Irwin S Basics When discussing the S environment, I will, or at least try to, make the following distinctions. S will be used when what is
More informationObjectives. 1 Basic Calculations. 2 Matrix Algebra. Physical Sciences 12a Lab 0 Spring 2016
Physical Sciences 12a Lab 0 Spring 2016 Objectives This lab is a tutorial designed to a very quick overview of some of the numerical skills that you ll need to get started in this class. It is meant to
More informationIntroduction to MatLab. Introduction to MatLab K. Craig 1
Introduction to MatLab Introduction to MatLab K. Craig 1 MatLab Introduction MatLab and the MatLab Environment Numerical Calculations Basic Plotting and Graphics Matrix Computations and Solving Equations
More informationElements of a programming language 3
Elements of a programming language 3 Marcin Kierczak 21 September 2016 Contents of the lecture variables and their types operators vectors numbers as vectors strings as vectors matrices lists data frames
More informationIntroduction to scientific programming in R
Introduction to scientific programming in R John M. Drake & Pejman Rohani 1 Introduction This course will use the R language programming environment for computer modeling. The purpose of this exercise
More informationLab 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 informationWeek 1: Introduction to R, part 1
Week 1: Introduction to R, part 1 Goals Learning how to start with R and RStudio Use the command line Use functions in R Learning the Tools What is R? What is RStudio? Getting started R is a computer program
More informationDemo yeast mutant analysis
Demo yeast mutant analysis Jean-Yves Sgro February 20, 2018 Contents 1 Analysis of yeast growth data 1 1.1 Set working directory........................................ 1 1.2 List all files in directory.......................................
More informationIntroduction 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 informationAn 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 informationData 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 informationMatlab Tutorial and Exercises for COMP61021
Matlab Tutorial and Exercises for COMP61021 1 Introduction This is a brief Matlab tutorial for students who have not used Matlab in their programming. Matlab programming is essential in COMP61021 as a
More informationMatlab Tutorial for COMP24111 (includes exercise 1)
Matlab Tutorial for COMP24111 (includes exercise 1) 1 Exercises to be completed by end of lab There are a total of 11 exercises through this tutorial. By the end of the lab, you should have completed the
More informationObjectives. 1 Running, and Interface Layout. 2 Toolboxes, Documentation and Tutorials. 3 Basic Calculations. PS 12a Laboratory 1 Spring 2014
PS 12a Laboratory 1 Spring 2014 Objectives This session is a tutorial designed to a very quick overview of some of the numerical skills that you ll need to get started. Throughout the tutorial, the instructors
More informationStat 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 informationFirst Steps with R. 27 January, Install R 1. 2 Atomic Vectors R s Basic Types 2. 4 Matrix, data.frame, and 2-D Subsetting 7
First Steps with R Seth Falcon Martin Morgan 27 January, 2010 Contents 1 Install R 1 2 Atomic Vectors R s Basic Types 2 3 Subsetting Vectors 4 3.1 Integer subsetting........................... 4 3.2 Logical
More informationStat405. More about data. Hadley Wickham. Tuesday, September 11, 12
Stat405 More about data Hadley Wickham 1. (Data update + announcement) 2. Motivating problem 3. External data 4. Strings and factors 5. Saving data Slot machines they be sure casinos are honest? CC by-nc-nd:
More informationPractical 2: Plotting
Practical 2: Plotting Complete this sheet as you work through it. If you run into problems, then ask for help - don t skip sections! Open Rstudio and store any files you download or create in a directory
More informationSTAT 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 informationStatlab Workshop on S-PLUS
Statlab Workshop on S-PLUS Instructor: Marios Panayides September 25, 2003 1 General Outline This S-PLUS basics workshop will mainly focus on the S programming language through the S-PLUS software package.
More informationComputational Modelling 102 (Scientific Programming) Tutorials
COMO 102 : Scientific Programming, Tutorials 2003 1 Computational Modelling 102 (Scientific Programming) Tutorials Dr J. D. Enlow Last modified August 18, 2003. Contents Tutorial 1 : Introduction 3 Tutorial
More informationR 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 informationMatlab for FMRI Module 1: the basics Instructor: Luis Hernandez-Garcia
Matlab for FMRI Module 1: the basics Instructor: Luis Hernandez-Garcia The goal for this tutorial is to make sure that you understand a few key concepts related to programming, and that you know the basics
More informationR version ( ) Copyright (C) 2010 The R Foundation for Statistical Computing ISBN
Math 3070 1. Treibergs Railway Example: Power of One Sample t-test Name: Example May 25, 2011 The power of a t-test is described by the operation characteristic curves of Table A.17 in Devore. It is also
More informationAn Introduction to MATLAB See Chapter 1 of Gilat
1 An Introduction to MATLAB See Chapter 1 of Gilat Kipp Martin University of Chicago Booth School of Business January 25, 2012 Outline The MATLAB IDE MATLAB is an acronym for Matrix Laboratory. It was
More information1 Matrices and Vectors and Lists
University of Wollongong School of Mathematics and Applied Statistics STAT231 Probability and Random Variables 2014 Second Lab - Week 4 If you can t finish the log-book questions in lab, proceed at home.
More informationStatistics 13, Lab 1. Getting Started. The Mac. Launching RStudio and loading data
Statistics 13, Lab 1 Getting Started This first lab session is nothing more than an introduction: We will help you navigate the Statistics Department s (all Mac) computing facility and we will get you
More informationArmstrong 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 informationMicrosoft Excel Level 2
Microsoft Excel Level 2 Table of Contents Chapter 1 Working with Excel Templates... 5 What is a Template?... 5 I. Opening a Template... 5 II. Using a Template... 5 III. Creating a Template... 6 Chapter
More information1. Turn on your laptop. The power button/key is in the topright corner of your keyboard.
1. Turn on your laptop. The power button/key is in the topright corner of your keyboard. 2. When the welcome box appears, click the highlighted button that says Let s Get Started If you do NOT see the
More informationLab copy. Do not remove! Mathematics 152 Spring 1999 Notes on the course calculator. 1. The calculator VC. The web page
Mathematics 152 Spring 1999 Notes on the course calculator 1. The calculator VC The web page http://gamba.math.ubc.ca/coursedoc/math152/docs/ca.html contains a generic version of the calculator VC and
More informationSTAT 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 informationS E C T I O N O V E R V I E W
AN INTRODUCTION TO SHELLS S E C T I O N O V E R V I E W Continuing from last section, we are going to learn about the following concepts: understanding quotes and escapes; considering the importance of
More informationGetting Started with DADiSP
Section 1: Welcome to DADiSP Getting Started with DADiSP This guide is designed to introduce you to the DADiSP environment. It gives you the opportunity to build and manipulate your own sample Worksheets
More informationLab 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 informationAn Introductory Guide to R
An Introductory Guide to R By Claudia Mahler 1 Contents Installing and Operating R 2 Basics 4 Importing Data 5 Types of Data 6 Basic Operations 8 Selecting and Specifying Data 9 Matrices 11 Simple Statistics
More information> glucose = c(81, 85, 93, 93, 99, 76, 75, 84, 78, 84, 81, 82, 89, + 81, 96, 82, 74, 70, 84, 86, 80, 70, 131, 75, 88, 102, 115, + 89, 82, 79, 106)
This document describes how to use a number of R commands for plotting one variable and for calculating one variable summary statistics Specifically, it describes how to use R to create dotplots, histograms,
More informationIn this exercise you will practice working with HDFS, the Hadoop. You will use the HDFS command line tool and the Hue File Browser
Access HDFS with Command Line and Hue Data Files (local): ~/labs/data/kb/* ~/labs/data/base_stations.tsv In this exercise you will practice working with HDFS, the Hadoop Distributed File System. You will
More informationA very brief Matlab introduction
A very brief Matlab introduction Siniša Krajnović January 24, 2006 This is a very brief introduction to Matlab and its purpose is only to introduce students of the CFD course into Matlab. After reading
More informationChapter 2: Descriptive Statistics: Tabular and Graphical Methods
Chapter 2: Descriptive Statistics: Tabular and Graphical Methods Example 1 C2_1
More informationEXCEL 98 TUTORIAL Chemistry C2407 fall 1998 Andy Eng, Columbia University 1998
Created on 09/02/98 11:58 PM 1 EXCEL 98 TUTORIAL Chemistry C2407 fall 1998 Andy Eng, Columbia University 1998 Note for Excel 97 users: All features of Excel 98 for Macintosh are available in Excel 97 for
More informationSTAT 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 informationR (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 informationComputer Project: Getting Started with MATLAB
Computer Project: Getting Started with MATLAB Name Purpose: To learn to create matrices and use various MATLAB commands. Examples here can be useful for reference later. MATLAB functions: [ ] : ; + - *
More informationLab 1 Introduction to MATLAB and Scripts
Lab 1 Introduction to MATLAB and Scripts EE 235: Continuous-Time Linear Systems Department of Electrical Engineering University of Washington The development of these labs was originally supported by the
More informationAn 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 informationControl 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 informationIntroduction to Scientific Computing with Matlab
UNIVERSITY OF WATERLOO Introduction to Scientific Computing with Matlab SAW Training Course R. William Lewis Computing Consultant Client Services Information Systems & Technology 2007 Table of Contents
More informationIntroduction to Matlab
What is Matlab? Introduction to Matlab Matlab is software written by a company called The Mathworks (mathworks.com), and was first created in 1984 to be a nice front end to the numerical routines created
More informationLaboratory 1 Octave Tutorial
Signals, Spectra and Signal Processing Laboratory 1 Octave Tutorial 1.1 Introduction The purpose of this lab 1 is to become familiar with the GNU Octave 2 software environment. 1.2 Octave Review All laboratory
More informationEntering 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 informationDownloaded from Chapter 2. Functions
Chapter 2 Functions After studying this lesson, students will be able to: Understand and apply the concept of module programming Write functions Identify and invoke appropriate predefined functions Create
More informationMobile Signing Science Picture Dictionary User s Guide
Mobile Signing Science Picture Dictionary User s Guide Welcome to the Mobile Signing Science Picture Dictionary (MSSP)! The MSSP can be used anytime, anywhere! It is an interactive 3D sign language mobile
More informationPackage adaptivetau. October 25, 2016
Type Package Title Tau-Leaping Stochastic Simulation Version 2.2-1 Date 2016-10-24 Author Philip Johnson Maintainer Philip Johnson Depends R (>= 2.10.1) Enhances compiler Package adaptivetau
More informationProgramming 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 informationUNIT 4. Research Methods in Business
UNIT 4 Preparing Data for Analysis:- After data are obtained through questionnaires, interviews, observation or through secondary sources, they need to be edited. The blank responses, if any have to be
More informationIntroduction to R for Beginners, Level II. Jeon Lee Bio-Informatics Core Facility (BICF), UTSW
Introduction to R for Beginners, Level II Jeon Lee Bio-Informatics Core Facility (BICF), UTSW Basics of R Powerful programming language and environment for statistical computing Useful for very basic analysis
More informationLAB #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 informationEE 216 Experiment 1. MATLAB Structure and Use
EE216:Exp1-1 EE 216 Experiment 1 MATLAB Structure and Use This first laboratory experiment is an introduction to the use of MATLAB. The basic computer-user interfaces, data entry techniques, operations,
More informationLAB 2: Linear Equations and Matrix Algebra. Preliminaries
Math 250C, Section C2 Hard copy submission Matlab # 2 1 Revised 07/13/2016 LAB 2: Linear Equations and Matrix Algebra In this lab you will use Matlab to study the following topics: Solving a system of
More information