Difference between revisions of "R tutorial"

From "A B C"
Jump to navigation Jump to search
Line 34: Line 34:
  
 
;Help
 
;Help
:Help is available for all commands and for the R command line syntax. As well, help is available to find the names of commands when you are not sure of them.
+
:Help is available for all commands and for the R command line syntax. As well, help is available to find the names of commands when you are not sure of them.  
  
 
<source lang="R">
 
<source lang="R">

Revision as of 14:18, 11 February 2012

R tutorial


This page is a placeholder, or under current development; it is here principally to establish the logical framework of the site. The material on this page is correct, but incomplete.


This is a tutorial introduction to R for users with no previous background in the platform or the language.



 

The environment

In this section we discuss how to download and install the software, how to configure an R session and what work with the R environment includes.

Installation

  1. Navigate to http://probability.ca/cran/ [1] and follow the link to your computer's operating system.
  2. Download a precompiled binary (or "build") of the R "framework" to your computer and follow the instructions for installing it. You don't need tools, or GUI versions for now, but do make sure that the program is the correct one for your version of your operating system.
  3. Launch R.

The program should open with the "R console", and greet you with its prompt, awaiting your input:

>

User interface

R comes with a GUI[2] to lay out common tasks. For example, there are a number of menu items, many of which are similar to other programs you will have worked with ("File", "Edit", "Format", "Window", "Help" ...). All of these tasks can also be accessed through the command line. In general, GUIs are useful when you are not sure what you want to do or how to go about it; the command line is much more powerful when you have more experience and know your way around in principle. R gives you both options.

Let's begin with a glossary of some terms that R uses and how they relate to your work:

Help
Help is available for all commands and for the R command line syntax. As well, help is available to find the names of commands when you are not sure of them.
a <- 5
Working directory


Workspace

wd, help, menu items, workspace, loading and running scripts

Packages

Standard packages included, data available

Documents

... Loading and running scripts


 

Simple commands

Including functions


 

Scalar datatypes

Definition, change, operations with, functions to work on...

 

Vectors

 

Matrices, tables, frames

Subsetting,mselecting and filtering


 

Data manipulations

Transformation Search


 

Writing functions

 

Installing new functions

 

Numeric output

 

Graphic output

 

Notes

  1. This is the CRAN mirror site at the University of Toronto, any other mirror site will do. You may access a choice of mirror sites from the R-project homepage.
  2. Graphical User Interface


 

Further reading and resources