Basics of R. > x=2 (or x<-2) > y=x+3 (or y<-x+3)

Size: px
Start display at page:

Download "Basics of R. > x=2 (or x<-2) > y=x+3 (or y<-x+3)"

Transcription

1 Basics of R 1. Arithmetic Operators > 2+2 > sqrt(2) # (2) >2^2 > sin(pi) # sin(π) >(1-2)*3 > exp(1) # e 1 >1-2*3 > log(10) # This is a short form of the full command, log(10, base=e). (Note) For log 10 7, use > log(10,7). (Note) Continuation prompt '+' Try >sqrt(2. Then you will see a prompt '+' on the next line. That means your command is incomplete, and R is waiting further action from you. Just type ) after '+' sign. 2. Assignment (= or <-) ; Mostly, naming a value is convenient for using it later. ; Put a name on the left-hand side of the equal sign and the value on the right of a equal sign (=) or the sign <-. > x=2 (or x<-2) > y=x+3 (or y<-x+3)

2 3. Entering data 3.1 Data vector using c( ) 3.1.a Numeric data Suppose you have a data set which is the number of whale beaching per year in Texas during the 1990s. The data set is > whales.tx=c(74, 122, 235, 111, 292, 111, 211, 133, 156, 79) ; The values are separated by a comma. Once stored, the values can be printed by typing the variable name. > whales.tx [1] (Note) '[1]' means the first observation. If more than one row is output, then this number refers to the first observation in each row of the output. (NOTE) The c( ) function can also combine data vectors. For example, > x=c(74,122,235,111,292) > y=c(111,211,133,156,79) > c(x,y) [1] (Note) Some functions with a numeric data vectors > sum(whales.tx) ; sum of data points in the data vector > length(whales,tx) ; length of data vector > sum(whales.tx)/length(whales.tx) ; average > mean(whales.tx) ; average (Note) Try other functions: sort(), min(), max(), range(), diff(), cusum() 3.1.b Character data If a data set consists of character values, then > simpsons=c( Homer, 'Marge', Bart ) ; character strins are made with maching quotes, either double,, or single, '. (Note) If we mix the type within a data vector, the data will be coerced into a common type, which is usually a character. This can prevent arithmetic operations Data vector using scan( ) You can use scan( ) function interactively on the screen. It reads data until a blank line is entered. For example, > x=scan() 1: : Read 8 items (Note) The scan ( ) function read an external (text or ASCII-formatted) data file. Suppose the Texas whale data were stored in a file named by whales_tx.txt in text or ASCII format. Then >whales.tx=scan(file= whale_tx.txt ) Read 10 items. (see '7. Importing/exporting data/output')

3 4. Element-by-element arithmetic operation with data vectors Suppose we also have another data set, which contains the number of whales that beached in Florida during the 1990s. The data set consists of 10 data points as follows >whales.fl=c(89, 254,292,274,233,294,204,204,90) >whales.tx+whales.tx [1] >whales.tx-whales.fl [1] Try the following command. > whales.tx-mean(whales.tx) (Example) Write an R program to calculate variance of the following data: > x=c(2,3,5,7,11) > n=length(x) > n [1] 5 > xbar=mean(x) > x-xbar [1] 5.6 >sum((x-xbar)^2) [1]51.2 >sum((x-xbar)^2)/(n-1) [1] 12.8 (Note) You can also use 'var()' function. Try 'var(x)'. You will get the same answer.

4 5. Matrix and matrix computation matrix (data, nrow=, ncol=, byrow=t) data: a list of the elements that fill the matrix nrow, ncol: the dimension of matrix byrow: specifies the rule that the matrix is to be filled. If byrow=f, then the matrix is filled column by column. Otherwise, it is filled row by row. The default is byrow=f. > p=seq(1:6) # seq(a:b) means a, a+1, a+2,..., b > p [1] > DF=matrix(p, nrow=2,ncol=3, byrow=f) # DF is filled by column by column [1,] [2,] > DT=matrix(p, nrow=2,ncol=3, byrow=t) # DT is filled by row by row [1,] [2,] > DD=matrix(p, nrow=2,ncol=3) # The default (if 'byrow' is not specified) is byrow=f [1,] [2,] > dim(dd) # the dimension of DD [1] 2 3 # 2 by 3 matrix > DD[2,] # elements of the 2 nd row [1] > DF[,3] # elements of the 3 rd column [1] 5 6 > DF[,2:3] # elements of the 2 nd to the 3 rd column [,1] [,2] [1,] 3 5 [2,] 4 6 > Y=matrix(c(1,2,3,4,5,6),nrow=3,ncol=2) # creating a 3-by-2 matrix Y > Y [,1] [,2] [1,] 1 4 [2,] 2 5 [3,] 3 6 > dim(y) [1] 3 2 # 3-by-2 matrix > X=matrix(c(7,8,9,10,11,12),nrow=2,ncol=3) # creating a 2-by-3 matrix X > X [1,] [2,] > t(y) # transpose of Y [1,] [2,] > Z=matrix(c(7,8,9),nrow=3,ncol=1) > Z [,1] [1,] 7 [2,] 8 [3,] 9

5 > V=matrix(c(10,20,30),nrow=1,ncol=3) > V [1,] > A=cbind(Y,Z) # combining the columns of Y and Z > A [1,] [2,] [3,] > B=rbind(X,V) # combining the rows of X and V > B [1,] [2,] [3,] > X=matrix(c(1,2,3,4,5,6),nrow=3,ncol=2) > y=matrix(c(7,8,9), nrow=3, ncol=1) > betahat=solve(t(x) %*% X) %*% t(x) %*% y # calculating ( X ' X ) 1 X ' y > betahat [,1] [1,] -1 [2,] 2 > m=nrow(x) # the number of rows of X > n=ncol(x) # the number of columns of X > m [1] 3 > n [1] 2 > y^2 # element-wise calculation [,1] [1,] 49 [2,] 64 [3,] 81 > y*y # element-wise calculation [,1] [1,] 49 [2,] 64 [3,] 81 > c(b) # deconstructing the matrix B; combining all column vectors of B [1]

6 6. Changing working directory Working directory is a directory in which a data file to be read or an output file to be written is located. Once you specify a working directory in the beginning of your program, you can read a data file or write an output file by specifying its file name only (without its directory path). > getwd( ) # checking the current working directory > setwd( directory path ) # setting a working directory Note: Forward slash (/) should be used as the path separator (Example) If you want to set a subdirectory new_dir under the Users directory in your computer to a new working directory, > setwd( /Users/new_dir ) 7. Importing/exporting data/output 7.1 Importing external data scan( ) ; reads logical, integer, numeric, complex, character,... scan(file = " ", what =, sep = "", skip =,quiet=,nlines=) file: the external file name to be read what: data type (logical, integer, numeric, complex, character); sep: delimiter between data (or field separator character). Sep = means that the separator is white space (one or more spaces, tabs). Sep= \t means the separator is tab. skip: specifies the number of lines to skip before beginning to read data values quiet: if FALSE (default), scan() will print a line, saying how many items have been read. nlines: if positive, the maximum number of lines of data to be read (Example 1) Suppose that a data file, 'a.txt', in the current working directory has the following format: b b b b4 Then, we can read the file using scan( ) function: > q=scan(file="a.txt",what="character") > q[3] [1] b1 > q[4] [1] 200 (Example 2) Suppose that a data file, 'b.txt', in the current working directory has the following format: x y z b b b b4 Then, we can read the file using scan( ) function: > q=scan(file="b.txt",what="character",skip=1) > q[3] [1] b1 > q[4] [1] 200

7 7.1.2 read.table( ) ; reads a file in table format read.table(file, header = FALSE, sep = "", dec = ".", skip=, row.names, col.names) header: indicates whether the file to be read contains variable names in the first line row.names: a vector of row names col.names: a vector of column names (Example 1) Suppose that a data file, 'b.txt', in the current working directory has the following format: x y z b b b b4 > r1=read.table("b.txt",header=t) > r1 x y z b b b b4 > dim(r1) [1] 4 3 # b.txt was read as a 4 by 3 matrix > r1[2,3] # accessing the (2,3) element [1] b2 > r1[,2] # accessing the 2 nd column elements [1] > r1[,"y"] # accessing the 2 nd column elements [1] read.csv ( ) ; reads data file in which data are separated by comma read.csv(file, header = TRUE, sep = ",", dec=".") 7.2 Exporting data write( ) ; writes a matrix or vector in a specified number of columns. write (x, file = "x.txt", ncolumns =, append = FALSE, sep = " ") x: the data in R to be exported file: x is exported with a name x.txt ncolumns: the number of columns append: if append=true, x is appended to the file x.txt write.table( ) ; writes a data frame with row and column labels write.table(x, file = "", append = FALSE, sep = " ", na = "NA", dec = ".") na: specify the string for missing values in the data (default is NA)

8 8. Writing outputs from an R session into an external file > sink( sinkout.txt ) > a=5 >a # The value of a, 5, is not shown in the screen but stored in the external file, sinkout.txt. > b=a+10 > b >sink() >unlink( sinkout.txt ) # Writing outputs into sinkout.txt is terminated. > a [1] 5 > b [1] Batch execution of an R program ; useful for executing a simulation program and storing its output to an external file. Outside R, R --vanilla <input file> output file&

Input/Output Data Frames

Input/Output Data Frames Input/Output Data Frames Statistics 135 Autumn 2005 Copyright c 2005 by Mark E. Irwin Input/Output Importing text files Rectangular (n rows, c columns) Usually you want to use read.table read.table(file,

More information

IST 3108 Data Analysis and Graphics Using R. Summarizing Data Data Import-Export

IST 3108 Data Analysis and Graphics Using R. Summarizing Data Data Import-Export IST 3108 Data Analysis and Graphics Using R Summarizing Data Data Import-Export Engin YILDIZTEPE, PhD Working with Vectors and Logical Subscripts >xsum(x) how many of the values were less than

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

Topics 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 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 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

STAT 540 Computing in Statistics

STAT 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 information

Reading in data. Programming in R for Data Science Anders Stockmarr, Kasper Kristensen, Anders Nielsen

Reading in data. Programming in R for Data Science Anders Stockmarr, Kasper Kristensen, Anders Nielsen Reading in data Programming in R for Data Science Anders Stockmarr, Kasper Kristensen, Anders Nielsen Data Import R can import data many ways. Packages exists that handles import from software systems

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

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

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

Data Input/Output. Andrew Jaffe. January 4, 2016

Data Input/Output. Andrew Jaffe. January 4, 2016 Data Input/Output Andrew Jaffe January 4, 2016 Before we get Started: Working Directories R looks for files on your computer relative to the working directory It s always safer to set the working directory

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

Intermediate Programming in R Session 1: Data. Olivia Lau, PhD

Intermediate Programming in R Session 1: Data. Olivia Lau, PhD Intermediate Programming in R Session 1: Data Olivia Lau, PhD Outline About Me About You Course Overview and Logistics R Data Types R Data Structures Importing Data Recoding Data 2 About Me Using and programming

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

BIO5312: R Session 1 An Introduction to R and Descriptive Statistics

BIO5312: R Session 1 An Introduction to R and Descriptive Statistics BIO5312: R Session 1 An Introduction to R and Descriptive Statistics Yujin Chung August 30th, 2016 Fall, 2016 Yujin Chung R Session 1 Fall, 2016 1/24 Introduction to R R software R is both open source

More information

Reading and writing data

Reading and writing data An introduction to WS 2017/2018 Reading and writing data Dr. Noémie Becker Dr. Sonja Grath Special thanks to: Prof. Dr. Martin Hutzenthaler and Dr. Benedikt Holtmann for significant contributions to course

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

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

IMPORTING DATA IN R. Introduction read.csv

IMPORTING DATA IN R. Introduction read.csv IMPORTING DATA IN R Introduction read.csv Importing data in R? 5 types Flat files Data from Excel Databases Web Statistical software Flat Files states.csv Comma Separated Values state,capital,pop_mill,area_sqm

More information

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

II.Matrix. Creates matrix, takes a vector argument and turns it into a matrix matrix(data, nrow, ncol, byrow = F)

II.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 information

IMPORTING DATA INTO R. Introduction Flat Files

IMPORTING DATA INTO R. Introduction Flat Files IMPORTING DATA INTO R Introduction Flat Files Importing data into R? 5 Types Flat Files Excel Files Statistical Software Databases Data from the Web Flat Files states.csv Comma Separated Values state,capital,pop_mill,area_sqm

More information

POL 345: Quantitative Analysis and Politics

POL 345: Quantitative Analysis and Politics POL 345: Quantitative Analysis and Politics Precept Handout 1 Week 2 (Verzani Chapter 1: Sections 1.2.4 1.4.31) Remember to complete the entire handout and submit the precept questions to the Blackboard

More information

Bjørn Helge Mevik Research Computing Services, USIT, UiO

Bjørn Helge Mevik Research Computing Services, USIT, UiO 23.11.2011 1 Introduction to R and Bioconductor: Computer Lab Bjørn Helge Mevik (b.h.mevik@usit.uio.no), Research Computing Services, USIT, UiO (based on original by Antonio Mora, biotek) Exercise 1. Fundamentals

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

This document is designed to get you started with using R

This 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 information

EPIB Four Lecture Overview of R

EPIB 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 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

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 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

Introduction to Statistics using R/Rstudio

Introduction to Statistics using R/Rstudio Introduction to Statistics using R/Rstudio R and Rstudio Getting Started Assume that R for Windows and Macs already installed on your laptop. (Instructions for installations sent) R on Windows R on MACs

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

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

"no.loss"), FALSE) na.strings=c("na","#div/0!"), 72 # Ενσωματωμένες συναρτήσεις (build-in functions) του R

no.loss), FALSE) na.strings=c(na,#div/0!), 72 # Ενσωματωμένες συναρτήσεις (build-in functions) του R 71 72 # Ενσωματωμένες συναρτήσεις (build-in functions) του R ----------------------------------------- 73 read.table(file, header = FALSE, sep = "", quote = "\"'", 74 dec = ".", numerals = c("allow.loss",

More information

Package Rwinsteps. February 19, 2015

Package Rwinsteps. February 19, 2015 Version 1.0-1 Date 2012-1-30 Title Running Winsteps in R Package Rwinsteps February 19, 2015 Author Anthony Albano , Ben Babcock Maintainer Anthony Albano

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

Quick R Tutorial for Beginners

Quick R Tutorial for Beginners Quick R Tutorial for Beginners Version 0.3 2015-12-3 Rintaro Saito, University of California San Diego Haruo Suzuki, Keio University 0. Introduction R is one of the best languages to perform statistical

More information

Module 4. Data Input. Andrew Jaffe Instructor

Module 4. Data Input. Andrew Jaffe Instructor Module 4 Data Input Andrew Jaffe Instructor Data Input We used several pre-installed sample datasets during previous modules (CO2, iris) However, 'reading in' data is the first step of any real project/analysis

More information

Reading and writing data

Reading and writing data 25/10/2017 Reading data Reading data is one of the most consuming and most cumbersome aspects of bioinformatics... R provides a number of ways to read and write data stored on different media (file, database,

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

Package LaF. November 20, 2017

Package LaF. November 20, 2017 Type Package Title Fast Access to Large ASCII Files Version 0.8.0 Date 2017-11-16 Author Jan van der Laan Package LaF November 20, 2017 Maintainer Jan van der Laan Methods

More information

Introduction to R Commander

Introduction to R Commander Introduction to R Commander 1. Get R and Rcmdr to run 2. Familiarize yourself with Rcmdr 3. Look over Rcmdr metadata (Fox, 2005) 4. Start doing stats / plots with Rcmdr Tasks 1. Clear Workspace and History.

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

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

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

Importing data sets in R

Importing data sets in R Importing data sets in R R can import and export different types of data sets including csv files text files excel files access database STATA data SPSS data shape files audio files image files and many

More information

The goal of this handout is to allow you to install R on a Windows-based PC and to deal with some of the issues that can (will) come up.

The goal of this handout is to allow you to install R on a Windows-based PC and to deal with some of the issues that can (will) come up. Fall 2010 Handout on Using R Page: 1 The goal of this handout is to allow you to install R on a Windows-based PC and to deal with some of the issues that can (will) come up. 1. Installing R First off,

More information

DSC 201: Data Analysis & Visualization

DSC 201: Data Analysis & Visualization DSC 201: Data Analysis & Visualization Reading Data Dr. David Koop Data Frame A dictionary of Series (labels for each series) A spreadsheet with column headers Has an index shared with each series Allows

More information

int64 : 64 bits integer vectors

int64 : 64 bits integer vectors int64 : 64 bits integer vectors Romain François - romain@r-enthusiasts.com int64 version 1.1.2 Abstract The int64 package adds 64 bit integer vectors to R. The package provides the int64 and uint64 classes

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

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

University of Torino, Italy Earth Science Department. R Summer School

University of Torino, Italy Earth Science Department. R Summer School University of Torino, Italy Earth Science Department R Summer School COST Action ES0601 HOME: Advances in HOmogenisation MEthods for climate series: an integrated approach September 7 th -10 th, 2009 Physics

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

Introduction to R 21/11/2016

Introduction 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 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

Getting Started. Slides R-Intro: R-Analytics: R-HPC:

Getting Started. Slides R-Intro:   R-Analytics:   R-HPC: Getting Started Download and install R + Rstudio http://www.r-project.org/ https://www.rstudio.com/products/rstudio/download2/ TACC ssh username@wrangler.tacc.utexas.edu % module load Rstats %R Slides

More information

A brief introduction to R

A brief introduction to R A brief introduction to R Cavan Reilly September 29, 2017 Table of contents Background R objects Operations on objects Factors Input and Output Figures Missing Data Random Numbers Control structures Background

More information

.txt - Exporting and Importing. Table of Contents

.txt - Exporting and Importing. Table of Contents .txt - Exporting and Importing Table of Contents Export... 2 Using Add Skip... 3 Delimiter... 3 Other Options... 4 Saving Templates of Options Chosen... 4 Editing Information in the lower Grid... 5 Import...

More information

Introduction to R Benedikt Brors Dept. Intelligent Bioinformatics Systems German Cancer Research Center

Introduction to R Benedikt Brors Dept. Intelligent Bioinformatics Systems German Cancer Research Center Introduction to R Benedikt Brors Dept. Intelligent Bioinformatics Systems German Cancer Research Center What is R? R is a statistical computing environment with graphics capabilites It is fully scriptable

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

Stat405. More about data. Hadley Wickham. Tuesday, September 11, 12

Stat405. 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 information

Package csvread. August 29, 2016

Package csvread. August 29, 2016 Title Fast Specialized CSV File Loader Version 1.2 Author Sergei Izrailev Package csvread August 29, 2016 Maintainer Sergei Izrailev Description Functions for loading large

More information

Short Introduction to R

Short Introduction to R Short Introduction to R Paulino Pérez 1 José Crossa 2 1 ColPos-México 2 CIMMyT-México June, 2015. CIMMYT, México-SAGPDB Short Introduction to R 1/51 Contents 1 Introduction 2 Simple objects 3 User defined

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

Introduction to R and R-Studio Toy Program #1 R Essentials. This illustration Assumes that You Have Installed R and R-Studio

Introduction to R and R-Studio Toy Program #1 R Essentials. This illustration Assumes that You Have Installed R and R-Studio Introduction to R and R-Studio 2018-19 Toy Program #1 R Essentials This illustration Assumes that You Have Installed R and R-Studio If you have not already installed R and RStudio, please see: Windows

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

An Introduction to Statistical Computing in R

An Introduction to Statistical Computing in R An Introduction to Statistical Computing in R K2I Data Science Boot Camp - Day 1 AM Session May 15, 2017 Statistical Computing in R May 15, 2017 1 / 55 AM Session Outline Intro to R Basics Plotting In

More information

Chapter 7 File Access. Chapter Table of Contents

Chapter 7 File Access. Chapter Table of Contents Chapter 7 File Access Chapter Table of Contents OVERVIEW...105 REFERRING TO AN EXTERNAL FILE...105 TypesofExternalFiles...106 READING FROM AN EXTERNAL FILE...107 UsingtheINFILEStatement...107 UsingtheINPUTStatement...108

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

Basic R Part 1. Boyce Thompson Institute for Plant Research Tower Road Ithaca, New York U.S.A. by Aureliano Bombarely Gomez

Basic R Part 1. Boyce Thompson Institute for Plant Research Tower Road Ithaca, New York U.S.A. by Aureliano Bombarely Gomez Basic R Part 1 Boyce Thompson Institute for Plant Research Tower Road Ithaca, New York 14853-1801 U.S.A. by Aureliano Bombarely Gomez A Brief Introduction to R: 1. What is R? 2. Software and documentation.

More information

What R is. STAT:5400 (22S:166) Computing in Statistics

What R is. STAT:5400 (22S:166) Computing in Statistics STAT:5400 (22S:166) Computing in Statistics Introduction to R Lecture 5 September 9, 2015 Kate Cowles 374 SH, 335-0727 kate-cowles@uiowa.edu 1 What R is an integrated suite of software facilities for data

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

Lab 1. Introduction to R & SAS. R is free, open-source software. Get it here:

Lab 1. Introduction to R & SAS. R is free, open-source software. Get it here: Lab 1. Introduction to R & SAS R is free, open-source software. Get it here: http://tinyurl.com/yfet8mj for your own computer. 1.1. Using R like a calculator Open R and type these commands into the R Console

More information

Installing and Using R

Installing and Using R The National Animal Nutrition Program (NANP) Modeling Committee A National Research Support Project (NRSP-9) Supported by the Experiment Station Committee on Organization and Policy, The State Agricultural

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

simpler Using R for Introductory Statistics

simpler Using R for Introductory Statistics John Verzani y 2e+05 4e+05 6e+05 8e+05 20000 40000 60000 80000 120000 160000 Preface page i These notes are an introduction to using the statistical software package R for an introductory statistics course.

More information

Matlab Programming Arrays and Scripts 1 2

Matlab Programming Arrays and Scripts 1 2 Matlab Programming Arrays and Scripts 1 2 Mili I. Shah September 10, 2009 1 Matlab, An Introduction with Applications, 2 nd ed. by Amos Gilat 2 Matlab Guide, 2 nd ed. by D. J. Higham and N. J. Higham Matrix

More information

Step-by-step user instructions to the hamlet-package

Step-by-step user instructions to the hamlet-package Step-by-step user instructions to the hamlet-package Teemu Daniel Laajala May 26, 2018 Contents 1 Analysis workflow 2 2 Loading data into R 2 2.1 Excel format data.......................... 4 2.2 CSV-files...............................

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

IADS Batch Server User Guide. Version July 2014 SYMVIONICS Document SSD-IADS SYMVIONICS, Inc. All rights reserved.

IADS Batch Server User Guide. Version July 2014 SYMVIONICS Document SSD-IADS SYMVIONICS, Inc. All rights reserved. IADS Batch Server User Guide Version 8.1.2 July 2014 SYMVIONICS Document SSD-IADS-152 1996-2018 SYMVIONICS, Inc. All rights reserved. Table of Contents 1. IADS Batch Server...1 1.1. Batch Server... 1 1.2.

More information

MAT 343 Laboratory 1 Matrix and Vector Computations in MATLAB

MAT 343 Laboratory 1 Matrix and Vector Computations in MATLAB MAT 343 Laboratory 1 Matrix and Vector Computations in MATLAB In this laboratory session we will learn how to 1. Create matrices and vectors. 2. Manipulate matrices and create matrices of special types

More information

Data Input/Output. Introduction to R for Public Health Researchers

Data Input/Output. Introduction to R for Public Health Researchers Data Input/Output Introduction to R for Public Health Researchers Common new user mistakes we have seen 1. Working directory problems: trying to read files that R "can't find" RStudio can help, and so

More information

Interfacing with MS Office Conference 2017

Interfacing with MS Office Conference 2017 Conference 2017 Session Description: This session will detail procedures for importing/exporting data between AeriesSIS Web Version/AeriesSIS Client Version and other software packages, such as word processing

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

ANOMALY DETECTION ON MACHINE LOG

ANOMALY DETECTION ON MACHINE LOG ANOMALY DETECTION ON MACHINE LOG Data Mining Prof. Sunnie S Chung Ankur Pandit 2619650 Raw Data: NASA HTTP access logs It contain two month's of all HTTP requests to the NASA Kennedy Space Center WWW server

More information

Grace days can not be used for this assignment

Grace days can not be used for this assignment CS513 Spring 19 Prof. Ron Matlab Assignment #0 Prepared by Narfi Stefansson Due January 30, 2019 Grace days can not be used for this assignment The Matlab assignments are not intended to be complete tutorials,

More information

A Guide for the Unwilling S User

A Guide for the Unwilling S User A Guide for the Unwilling S User Patrick Burns Original: 2003 February 23 Current: 2005 January 2 Introduction Two versions of the S language are available a free version called R, and a commercial version

More information

Data input & output. Hadley Wickham. Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University.

Data input & output. Hadley Wickham. Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University. Data input & output Hadley Wickham Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University June 2012 1. Working directories 2. Loading data 3. Strings and factors

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

Hints about R. version 1.16, 20 January Georgi Boshnakov

Hints about R. version 1.16, 20 January Georgi Boshnakov Hints about R version 1.16, 20 January 2017 Georgi Boshnakov 1 Introduction R is a powerful system for data analysis. It is easily available to download R, go to the R Project site (just Google R and the

More information

UC Export Folders Version 3.5 for Worksite 8.x, 9.x x86

UC Export Folders Version 3.5 for Worksite 8.x, 9.x x86 UC Export Folders Version 3.5 for Worksite 8.x, 9.x x86 Exports folders and subfolders directly from workspaces, tabs and folders Filter documents and email messages Integrated into Filesite and Desksite

More information

ADVANCED INQUIRIES IN ALBEDO: PART 2 EXCEL DATA PROCESSING INSTRUCTIONS

ADVANCED INQUIRIES IN ALBEDO: PART 2 EXCEL DATA PROCESSING INSTRUCTIONS ADVANCED INQUIRIES IN ALBEDO: PART 2 EXCEL DATA PROCESSING INSTRUCTIONS Once you have downloaded a MODIS subset, there are a few steps you must take before you begin analyzing the data. Directions for

More information

Short Version of Matlab Manual

Short Version of Matlab Manual Short Version of Matlab Manual This is an extract from the manual which was used in MA10126 in first year. Its purpose is to refamiliarise you with the matlab programming concepts. 1 Starting MATLAB 1.1.1.

More information

R package

R package R package www.r-project.org Download choose the R version for your OS install R for the first time Download R 3 run R MAGDA MIELCZAREK 2 help help( nameofthefunction )? nameofthefunction args(nameofthefunction)

More information

Package gmt. September 12, 2017

Package gmt. September 12, 2017 Version 2.0-1 Date 2017-09-12 Package gmt September 12, 2017 Title Interface Between GMT Map-Making Software and R Imports utils SystemRequirements gmt LazyData yes Interface between the GMT map-making

More information

Reading data into R. 1. Data in human readable form, which can be inspected with a text editor.

Reading data into R. 1. Data in human readable form, which can be inspected with a text editor. Reading data into R There is a famous, but apocryphal, story about Mrs Beeton, the 19th century cook and writer, which says that she began her recipe for rabbit stew with the instruction First catch your

More information

MATLAB NOTES. Matlab designed for numerical computing. Strongly oriented towards use of arrays, one and two dimensional.

MATLAB NOTES. Matlab designed for numerical computing. Strongly oriented towards use of arrays, one and two dimensional. MATLAB NOTES Matlab designed for numerical computing. Strongly oriented towards use of arrays, one and two dimensional. Excellent graphics that are easy to use. Powerful interactive facilities; and programs

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

Laboratory 1 Octave Tutorial

Laboratory 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 information

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #16 Loops: Matrix Using Nested for Loop

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #16 Loops: Matrix Using Nested for Loop Introduction to Programming in C Department of Computer Science and Engineering Lecture No. #16 Loops: Matrix Using Nested for Loop In this section, we will use the, for loop to code of the matrix problem.

More information