RTutorial - Brief R Tutorial June 6, 2008 The best way to...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Brief R Tutorial June 6, 2008 The best way to go through this tutorial is to first install a version of R (see installation section below) and type the commands along with the examples given. This way you can see for yourself what output each command gives. Contents 1 Introduction 2 2 R Basics - Installation, Starting, Quitting, and Objects 2 3 Entering or Reading Data Into R 2 3.1 Typing Data In Manually . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 3.2 Reading Data From a File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 3.3 Accessing Elements of Data Arrays, Vectors, or Matrices . . . . . . . . . . . . . . . . . . . . . 4 3.4 Determining Sizes of Data Structures/Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 4 Basic R Commands You Should Know 4 5 Statistical Commands You Should Know 4 6 Writing Your Own Functions and Sourcing Code 5 6.1 Writing a Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 6.2 For and While Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 6.3 Logical Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 6.4 Sourcing Code and Setting the Working Directory . . . . . . . . . . . . . . . . . . . . . . . . 6 7 Graphics 7 7.1 Creating a pdf or ps File of an R Figure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 8 Writing Output To A File 7 9 Installing Packages 8 1 1 Introduction R is a statistical programming language that provides many built in functions for performing statistical analysis. R is also flexible enough to allow users to write their own functions and source code written in a text editor such as NotePad or Emacs. The advantage to learning R is that R is very easy to learn and easy to use. However, R is quite slow when doing heavy computational work (such as Bayesian algorithms) and so using R for heavy computing is not recommended. This tutorial provides a very brief introduction to how to use R. This document will go through some of the most commonly used R functions but will in no way cover all of the functions in R. To learn advanced R functions, you should use Internet searches with the key word CRAN which stands for Comprehensive R Archive Network. Using the key word CRAN in addition to other key words about the function you are looking for will generally produce a lot of results. If you forget the specific syntax for the R functions listed in this tutorial, you can simply type ?function and R will return the documentation for function which will provide almost all the necessary information for using function . As an example, typing ?qnorm will return the documentation for the R function qnorm ....
View Full Document

This note was uploaded on 10/09/2009 for the course STAT 471 taught by Professor Cabrera during the Spring '09 term at Rutgers.

Page1 / 8

RTutorial - Brief R Tutorial June 6, 2008 The best way to...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online