S Programming in R Bill Venables CSIRO Mathematics and Information Sciences Auckland, 7 July 2006.

Slides:



Advertisements
Similar presentations
Introduction to S-Plus by Francesco Ferretti Analysis of Biological Data Course Winter term 2007 Dalhousie University.
Advertisements

Sue Wills July Objects The JavaScript language is completely centered around objects, and because of this, it is known as an Object Oriented Programming.
Parts of a Computer.
M AT L AB Programming: scripts & functions. Scripts It is possible to achieve a lot simply by executing one command at a time on the command line (even.
MATLAB – What is it? Computing environment / programming language Tool for manipulating matrices Many applications, you just need to get some numbers in.
Utilizing the GDB debugger to analyze programs Background and application.
 Statistics package  Graphics package  Programming language  Can be used to share/reproduce analyses  Many new packages being created - can be downloaded.
Basics of Using R Xiao He 1. AGENDA 1.What is R? 2.Basic operations 3.Different types of data objects 4.Importing data 5.Basic data manipulation 2.
Introduction to GTECH 201 Session 13. What is R? Statistics package A GNU project based on the S language Statistical environment Graphics package Programming.
Programming Fundamentals. Programming concepts and understanding of the essentials of programming languages form the basis of computing.
SHOU Haochang ( 寿昊畅 ) Department of Biostatistics, Johns Hopkins Bloomberg School of Public Health July 11th, 2011 Nanjing University, China *Thanks to.
CVEV 118/698 Visual Basic Lecture 3 Prof. Mounir Mabsout Elsa Sulukdjian Walid El Asmar.
Introduction to MATLAB Northeastern University: College of Computer and Information Science Co-op Preparation University (CPU) 10/22/2003.
Alternative text for elementary statistics –Elementary Concepts –Basic Statistics.
Guide To UNIX Using Linux Third Edition
Shell Programming 1. Understanding Unix shell programming language: A. It has features of high-level languages. B. Convenient to do the programming. C.
How to Use the R Programming Language for Statistical Analyses Part I: An Introduction to R Jennifer Urbano Blackford, Ph.D. Department of Psychiatry Kennedy.
Introduction to Array The fundamental unit of data in any MATLAB program is the array. 1. An array is a collection of data values organized into rows and.
Statistical Software An introduction to Statistics Using R Instructed by Jinzhu Jia.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 25 – Perl and CGI (Common Gateway Interface) Outline 25.1 Introduction 25.2 Perl 25.3 String Processing.
Programming For Nuclear Engineers Lecture 12 MATLAB (3) 1.
TH-OCR NK. content introduction go to next page background assumptions overall structure chart IPO for overall structure dataflow diagram of overall structure.
What is R By: Wase Siddiqui. Introduction R is a programming language which is used for statistical computing and graphics. “R is a language and environment.
R Data Import/Export Dr. Jieh-Shan George YEH
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
Word Processing ADE100- Computer Literacy Lecture 12.
JavaScript, Fourth Edition
Objectives Understand what MATLAB is and why it is widely used in engineering and science Start the MATLAB program and solve simple problems in the command.
Chapter Four UNIX File Processing. 2 Lesson A Extracting Information from Files.
Guide To UNIX Using Linux Fourth Edition
Introduction to Unix (CA263) File Processing. Guide to UNIX Using Linux, Third Edition 2 Objectives Explain UNIX and Linux file processing Use basic file.
An Introduction to Unix Shell Scripting
Introduction to to R Emily Kalah Gade University of Washington Credit to Kristin Siebel for development of much of this PowerPoint.
CS 497C – Introduction to UNIX Lecture 7: General-Purpose Utilities Chin-Chih Chang
Chapter 8 Cookies And Security JavaScript, Third Edition.
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room A, Chris Hill, Room ,
Introduction to Engineering MATLAB – 6 Script Files - 1 Agenda Script files.
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.
Introduction of Geoprocessing Topic 7a 4/10/2007.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
Introduction to R / sma / Bioconductor Statistics for Microarray Data Analysis The Fields Institute for Research in Mathematical Sciences May 25, 2002.
Hands-on Introduction to R. We live in oceans of data. Computers are essential to record and help analyse it. Competent scientists speak C/C++, Java,
R packages/libraries Data input/output Rachel Carroll Department of Public Health Sciences, MUSC Computing for Research I, Spring 2014.
Editors And Debugging Systems Other System Software Text Editors Interactive Debugging Systems UNIT 5 S.Sharmili Priyadarsini.
1 Programming Fundamentals How to Program in C++ How to Program in C++
GUI Design With The Appx Client Presented By: Gary Rogers.
Praat LING115 November 4, Getting started Basic phonetic analyses with Praat –Creating sound objects Recording, reading from a file, creating from.
Technology Vocabulary By: Rakeysha Patterson. Search Engine  A computer program that searches documents, especially on the World Wide Web, for a specified.
R Data Import/Export Dr. Jieh-Shan George YEH
Introduction to R Carol Bult The Jackson Laboratory Functional Genomics (BMB550) Spring 2011.
Postgraduate Computing Lectures PAW 1 PAW: Physicist Analysis Workstation What is PAW? –A tool to display and manipulate data. Learning PAW –See ref. in.
PROGRAMMING IN R Introduction to R. In this session I will: Introduce you to the R program and windows Show how to install R Write basic programs in R.
Introduction of Geoprocessing Lecture 9 3/24/2008.
Computer Eng. Software Lab II , Semester 2, Who I am: Andrew Davison CoE, WiG Lab Office Functional Programming.
Hands-on Introduction to R. We live in oceans of data. Computers are essential to record and help analyse it. Competent scientists speak C/C++, Java,
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
Creating a script create new blank document. Editor options Docking and undocking tabs.
Fundamentals of Programming I Overview of Programming
Introduction to programming in java
Release Numbers MATLAB is updated regularly
SQL and SQL*Plus Interaction
Lecture 1: R Basics.
Chapter Four UNIX File Processing.
Introduction Paul Flynn
UNIX File System Go Climb a Tree Weiyu Zhang (96142)
Basics of R, Ch Functions Help Managing your Objects
Introduction to MATLAB
Using SQL*Plus.
Lab 5: Complex Inputs.
Web Application Development Using PHP
Presentation transcript:

S Programming in R Bill Venables CSIRO Mathematics and Information Sciences Auckland, 7 July 2006

Session 1 Introduction Background, basic features and

7 July 2006S Programming in R3 The S Language “S is a language for manipulating objects” –A function language –An object oriented language Objects are the vehicle for information in S Objects may be –constructed –interrogated –displayed –compared –modified, …

7 July 2006S Programming in R4 Objects and classes “In S everything is an object and every object has a class”. Objects: –data (vectors, matrices, character vectors, …) –objects constructed from data (fitted models, graphics objects, &c) –functions and other language elements –connections (file, text, …) –classes themselves, meta data, –…

7 July 2006S Programming in R5 How are objects located? In one sense, on the search path > search() [1] ".GlobalEnv" ".R_Store" [3] "package:fortunes" "package:rpart" [5] "package:MASS" "package:ASOR" [7] "package:methods" "package:stats" [9] "package:graphics" "package:grDevices" [11] "package:utils" "package:datasets" [13] ".R_Utils" "package:svIDE" [15] "package:tcltk" "Autoloads" [17] "package:base"

7 July 2006S Programming in R6 What happens at startup? > ?.Rprofile Startup package:base R Documentation Initialization at Start of an R Session Description: In R, the startup mechanism is as follows......

7 July 2006S Programming in R7 More on startup Rprofile.site –File in R_HOME/etc –Invoked for all R sessions on the current machine –Probably best left alone.Rprofile –File in R_USER or current working directory –Invoked for all R sessions for this user (or with this working directory) –Very useful for setting options.Renviron, Rconsole, Rdevga

7 July 2006S Programming in R8 Getting Help in General Help on a specific object or entity: –?object ## and variants –help(object) –help.start() –RSiteSearch("keyword or phrase") Help on packages is similarly available, For a few packages –vignette("package_name") Gives an overview of what's available.

7 July 2006S Programming in R9 Adding to the search path –library(MASS) –require(MASS) –attach(list_object_or_data_frame) –detach(position_or_name ) Locally adding to the path –value ) –dataset <- transform(dataset, v1 = x1, v2 = x2,...) –dataset <- subset(dateset, condition, select =...) The ' data ' argument in fitting functions, lattice, &c

7 July 2006S Programming in R10 More convenience features The (unofficial) ASOR package Based on a CRAN package, 'gdata', by David Brahm, but not yet an official package – yet, Allows you to 'offload' objects from memory, while remaining visible on the search path, If objects are needed, they are placed back in memory –Attach() – makes saved objects visible –Save(...) – removes objects form.GlobalEnv –Objects() – lists offloaded objects attaching if necessary –Remove(...) – permanently removes saved objects. Uses the idea of a "promise" to load the object, if necessary. Not restricted to large objects

7 July 2006S Programming in R11 Some extracts from an.Rprofile options(show.signif.stars = FALSE, length = ) options(CRAN = " options(repos = c(CRAN = getOption("CRAN"), CRANextra = " options(save.defaults = list(compress = TRUE, ascii = FALSE, safe = TRUE)) autoload("xyplot", "lattice") autoload("odbcConnectExcel", "RODBC") autoload("stepAIC", "MASS")

7 July 2006S Programming in R12 Front ends Tinn-R –Windows only –Now requires R to run in SDI mode –Very useful front end for working with R and keeping a working script Emacs/ESS –Offers similar functionality –Available for Windows/Linux/Unix/Mac? Rcmdr and SciViews both offer front ends with strengths and weaknesses.

7 July 2006S Programming in R13 Some input and output scan() read.table(), read.csv(), read.delim(),... write.table(), write.csv(),... sink(), print(), cat() – standard source() data.dump(), data.restore() – hardly needed save(), save.image(), load(),... Connections – to external files or character string vectors RODBC package allows external connections to data bases –con <- odbcConnectExcel("microsoft.xls ")