R tutorial Stat 140 Linjuan Qian

Slides:



Advertisements
Similar presentations
Summary Statistics/Simple Graphs in SAS/EXCEL/JMP.
Advertisements

Lectures prepared by: Elchanan Mossel Yelena Shvets Introduction to probability Stat 134 FAll 2005 Berkeley Follows Jim Pitman’s book: Probability Section.
R: A Statistics Program For Teaching & Research Josué Guzmán 11 Nov. 2007
Basic spreadsheet commands (note on powerpoint) These powerpoint slides were made using the following menu options: View -- normal Insert -- new slide.
R tutorial g/methods2.2010/R-intro.pdf.
An Introduction to R: Monte Carlo Simulation MWERA 2012 Emily A. Price, MS Marsha Lewis, MPA Dr. Gordon P. Brooks.
EPSY 435 – Educational Statistics EPSY 435 Question – Assignment 10 In the OnLine Testing text area, explain the concept of the sampling distribution of.
STAT 270 What’s going to be on the quiz and/or the final exam?
Today: Run SAS programs on Saturn (UNIX tutorial) Runs SAS programs on the PC.
Mx? A programming language for scientific computation. Related Languages: Matlab IDL Maple, Mathcad, Mathematica.
Alternative text for elementary statistics –Elementary Concepts –Basic Statistics.
Engineering Probability and Statistics - SE-205 -Chap 3 By S. O. Duffuaa.
A random variable that has the following pmf is said to be a binomial random variable with parameters n, p The Binomial random variable.
Chapter 21 Random Variables Discrete: Bernoulli, Binomial, Geometric, Poisson Continuous: Uniform, Exponential, Gamma, Normal Expectation & Variance, Joint.
Training on R-language Mārtiņš Liberts Central Statistical Bureau of Latvia.
Applied Bioinformatics Introduction to Linux and R Bing Zhang Department of Biomedical Informatics Vanderbilt University
Probability Distributions 2014/04/07 Maiko Narahara
Introduction to MATLAB ENGR 1187 MATLAB 1. Programming In The Real World Programming is a powerful tool for solving problems in every day industry settings.
Basic R Programming for Life Science Undergraduate Students Introductory Workshop (Session 1) 1.
A Statistical Analysis Example of A Full Functional Utilization of An Engineering Calculator Li-Fei Huang Dept. of App. Statistics.
Fundamental Graphics in R Prof. Ke-Sheng Cheng Dept. of Bioenvironmental Systems Eng. National Taiwan University.
732A44 Programming in R.  Self-studies of the course book  2 Lectures (1 in the beginning, 1 in the end)  Labs (computer). Compulsory submission of.
Hands-on Introduction to R. Outline R : A powerful Platform for Statistical Analysis Why bother learning R ? Data, data, data, I cannot make bricks without.
Statistics for Engineer Week II and Week III: Random Variables and Probability Distribution.
Arko Barman with modification by C.F. Eick COSC 4335 Data Mining Spring 2015.
P366: Lecture #1 Use of Excel for analysis Lei Chen, MD Jan 6, 2002.
Piotr Wolski Introduction to R. Topics What is R? Sample session How to install R? Minimum you have to know to work in R Data objects in R and how to.
I❤RI❤R Kin Wong (Sam) Game Plan Intro R Import SPSS file Descriptive Statistics Inferential Statistics GraphsQ&A.
Using the R software R is an open source comprehensive statistical package, more and more used around the world. R project web site:
Installing R CRAN: –(R homepage: –Windows 95 and later  Base –rw2001.exe.
1 Topic 3 - Discrete distributions Basics of discrete distributions Mean and variance of a discrete distribution Binomial distribution Poisson distribution.
Chapter 2 Analysis using R. Few Tips for R Commands included here CANNOT ALWAYS be copied and pasted directly without alteration. –One major reason is.
Distributions, Iteration, Simulation Why R will rock your world (if it hasn’t already)
STAT 251 Lab 1. Outline Lab Accounts Introduction to R.
Simulations and programming in R. Why to simulate and program in R at all? ADVANTAGES –All R facilities can be used in the simulations Random number generators.
SPSS- Tutorial The following power-point slides show you how to use some of the features in SPSS. A survey of 20 randomly selected companies asked them.
Performing statistical analyses using the Rshell processor Original material by Peter Li, University of Birmingham, UK Adapted by Norman.
Computing for Research I Spring 2013
Introduction to R Carol Bult The Jackson Laboratory Functional Genomics (BMB550) Spring 2011.
Bioinformatics for biologists
2016/2/9System Arch (Fire Tom Wada)1 SCILAB Glance and demonstration By: Pham Thi Thu Phuong.
1. Starting 1 Let’s Learn Saenthong School, January – February 2016 Teacher: Aj. Andrew Davison, CoE, PSU Hat Yai Campus
MATH 2311 Help Using R-Studio. To download R-Studio Go to the following link: Follow the instructions for your computer.
Lecture 11 Introduction to R and Accessing USGS Data from Web Services Jeffery S. Horsburgh Hydroinformatics Fall 2013 This work was funded by National.
Descriptive Statistics using R. Summary Commands An essential starting point with any set of data is to get an overview of what you are dealing with You.
Before the class starts: 1) login to a computer 2) start RStudio 3) download Intro.R from MyCourses 4) open Intro.R in Rstudio 5) Download “R in Action”
1 Introduction to R A Language and Environment for Statistical Computing, Graphics & Bioinformatics Introduction to R Lecture 3
Pinellas County Schools
General Computer Science for Engineers CISC 106 Lecture 03 James Atlas Computer and Information Sciences 9/9/2009.
16BIT IITR Data Collection Module If you have not already done so, download and install R from download.
Statistics -Continuous probability distribution 2013/11/18.
Programming in R Intro, data and programming structures
Performing statistical analyses using the Rshell processor
Introduction to R Samal Dharmarathna.
From the binomial to the normal
IEE 380 Review.
Arko Barman COSC 6335 Data Mining Fall 2014
Probability for Machine Learning
Lab Week 3 HW 1 Collect body height and weight from 5 of your friends
R04: Basic Functions 林 建 甫 C.F. Jeff Lin, MD. PhD.
Univariate Data Exploration
Fundamental Graphics in R
CSCI N207 Data Analysis Using Spreadsheet
Continuous Statistical Distributions: A Practical Guide for Detection, Description and Sense Making Unit 3.
Sampling Distribution of the Mean in IML
R course 6th lecture.
Chapter 3 : Random Variables
Descriptive Statistics Frequency & Contingency Tables
R tutorial
1/2555 สมศักดิ์ ศิวดำรงพงศ์
Presentation transcript:

R tutorial Stat 140 Linjuan Qian

Accessing R “Windows”: free version of R can be downloaded from Also every machine in FAS lab and stat lab preinstalled R. Just open “R console”. “Unix”: login into nice.harvard.edu or stat.harvard.edu, type “R” at the Unix prompt. “Web-based”: copy and paste Using q() to quit from R Get help: help(mean) or help->Html help

Basic Stuff: Assignment operators: x<-c(1,2); y=c(3,4 ); a<-matrix(c(1,2,3,4), nrow=2, ncol=2); z<-cbind(x,y); w<-rbind(x,y); “matrix based”: everything is done as vectors. try x+y;x*y;x%*%y;x%*%t(y);solve(a) Arithmetic Operators: +,-,*,/,^ Comparison Operators : ==, !=, >, =, <= Logical Operators: &&, || Comment : #

Input data From command line: x <- c(1,2,3,4) Y = 1:100; Y=seq(1,100,1) new.vector <- rep(0, n) z <- matrix(Y, nrow=20, ncol=5) From data file: data<-read.table(“dataset.txt”, header=T)

Basic Statistics: Summmary: summary(vector),mean, var, sd Tests: t.test(vector), var.test(vector1, vector2) Sorting: max, min, sort Graph : hist(vector), boxplot, qqplot, plot Regression : model<- lm(z~x+y) Sampling: sample(x, 1000, replace=T, prob=NULL) Or next slide

Control Structure Condition: if(a==5){ b=1 } else if(a<=3){ b=2 } else{ b=3 } Loop : be aware, R is notorious for loops, try to avoid using loops as much as you can! while (a<3) {a=a+1} for (i in 1:10){x=x+i} break next

Functions about Distributions The names for various distributions are as follows: norm : normal;beta : beta chisq : chi squared;pois : Poisson gamma : gamma;binom : binomial nbinom: negative binomial;t : t;f : F unif: uniform; Then you can add one of four letters to each distribution to create a command: r: random draws d: density functions (pdf or pmf) q: quantiles p: cdf (cumulative probabilities) Example: rnorm(10, mean=0, sd=1); dnorm(0, mean=0, sd=1)

Enhance your productivity Save a series of command as a text file and run it as a program. Within R: source(“infile.txt”) Writing your own functions: my.function <- function(arguments) { content return(output) }

Other packages: Functions are grouped as packages Install packages: Windows menu: packages -> install.. Unix&Windows:install.packages("MASS") Load packages before use: library(MASS) help(mvrnorm)

Relevant to HW 1 Install a package called “gregmisc”, which offers the permutation and combination function. Input data values and compute basic statistics such as sum and mean For matrix, compute row/column mean “Filtering” out important values Plots and test commands can be easily found