introduction to r sofware
play

Introduction to R Sofware Advanced Herd Management Ccile Cornou 1 - PDF document

Introduction to R Sofware Advanced Herd Management Ccile Cornou 1 What is R? Programming environment for data analysis, statistical methods and graphical display Use a programming language very similar to S Object oriented


  1. Introduction to R Sofware Advanced Herd Management Cécile Cornou 1 What is R? • Programming environment for data analysis, statistical methods and graphical display • Use a programming language very similar to S • Object oriented system • Built-in or ”hand made” functions to apply on objects 2 1

  2. Access and Documentation • Downloading (Free software) Comprehensive R Archive Network http://cran.r-project.org • Documentation ”An Introduction to R” (from cran website) W.N. Venables, D.M. Smith and the R Development Core Team 3 Getting started with R • The R console • Set a working directory • Edit as text file (as notepad) and copy/paste • Import data from an excel spread sheet Previously saved as ”csv” file / Located in your directory • First calculation and plotting • Export data 4 2

  3. The R console 5 Working Directory (to import and export your data) 6 3

  4. Read data 7 Summary of the data and Plotting (basic) 8 4

  5. Plotting (enhanced) 9 Moving Average – R programming Here we use a created function ”movAve” to calculate Finally we can save the new table as csv file -the moving average of the daily gain for further calculations -the upper and lower control limits using the expected mean � write.table(table,file=”adg2.csv”) (mean1) and standard deviation of the process in control (sd1) movAve <- function(vector,span,nosigma,mean1,sd1) { n <- length(vector); ma <- rep(NA,n); for (i in (span : n)) { x <- c(vector[(i-span+1):i]); ma[i] <- mean(x); } ucl <- mean1 + nosigma*sd1; lcl <- mean1 - nosigma*sd1; return(list(ma=ma,ucl=ucl,lcl=lcl)); } Create an empty data frame to store the results res.ma <- data.frame() Calculate and store the results in the data frame res.ma <- movAve(table$Observed.gain,4,2,750,20) Add the moving average to our table table$ma <- res.ma$ma 10 5

  6. Control Chart: Moving Average 11 6

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend