What Is R
What Is R
R is a system for statistical analyses and graphics created by Ross Ihaka and Robert Gentleman.
R is both a software and a language considered as a dialect of the S language created by the AT&T Bell
Laboratories. S is available as the software S-PLUS commercialized by Insightful.
The files needed to install R, either from the sources or from the pre-compiled binaries, are distributed from the
internet site of the Comprehensive R Archive Network (CRAN).
R has many functions for statistical analyses and graphics.
The results from a statistical analysis are displayed on the screen, some intermediate results (P-values,
regression coefficients, residuals ...) can be saved, written in a file, or used in subsequent analyses.
R users may benefit from a large number of programs written for S and available on the internet, most of these
programs can be used directly with R.
R stores the results in “objects", so that an analysis can be done with no result displayed.
When R is running, variables, data, functions, results, etc., are stored in the active memory of the computer in
the form of objects which have a name.
The user can do actions on these objects with operators (arithmetic, logical, comparison . . .) and functions
(which are themselves objects).
R Basic Structure
All the actions of R are done on objects stored in the active memory of the computer: no temporary files are
used (Fig. 1).
The readings and writings of files are used for input and output of data and results (like graphics).
The user executes the functions via some commands.
The results are displayed directly on the screen, stored in an object, or written on the disk (particularly for
graphics). Since the results are themselves objects, they can be considered as data and analyzed as such.
Data files can be read from the local disk or from a remote server through internet.
The functions available to the user are stored in a library localized on the disk in a directory called R HOME/library
(R_HOME is the directory where R is installed).
This directory contains packages of functions, which are themselves structured in directories.
The package named base is in a way the core of R and contains the basic functions of the language, particularly, for
reading and manipulating data.
Each package has a directory called R with a file named like the package (for instance, for the package base, this is the
file R_HOME/library/base/R/base). This file contains all the functions of the package.
One of the simplest commands is to type the name of an object to display its content. For instance, if an object n
contents the value 10:
> n
[1] 10
The digit 1 within brackets indicates that the display starts at the first element of n.
This command is an implicit use of the function print and the above example is similar to print(n).
> n
[1] 1.581252
> ls()
[1] "b" "n"
> ls.str()
b : num [1:2] 0.606 -0.522
n : num 10
name : chr "anjum"
p : num 7
> rm(n)
> rm(n,b)
> rm(list=ls())
3 Data with R
Mode -> type {numeric, character, complex, logical} other mode exists but they don’t contain data like functions,
expressions.