R is a language and environment for statistical computing and graphics. It is a GNU project which is similar to the S language and environment which was developed at Bell Laboratories (formerly AT&T, now Lucent Technologies) by John Chambers and colleagues. R can be considered as a different implementation of S. There are some important differences, but much code written for S runs unaltered under R.
R provides a wide variety of statistical (linear and nonlinear modelling, classical statistical tests, time-series analysis, classification, clustering, …) and graphical techniques, and is highly extensible. The S language is often the vehicle of choice for research in statistical methodology, and R provides an Open Source route to participation in that activity.[Ref:www.r-project.org]
One of R’s strengths is the ease with which well-designed publication-quality plots can be produced, including mathematical symbols and formulae where needed. Great care has been taken over the defaults for the minor design choices in graphics, but the user retains full control.
R is available as Free Software under the terms of the Free Software Foundation’s GNU General Public License in source code form. It compiles and runs on a wide variety of UNIX platforms and similar systems (including FreeBSD and Linux), Windows and Mac OS [Ref:www.r-project.org].
Basic R programming Commands
1. 3+7
This statement simply adds 3 with 7 and gives output as below
[1] 10
2. X<-3 nbsp="" span="">-3>
This statement assigns
value 3 to variable X. To see the value of x, you can just type x on the prompt.
> x
[1] 3 // this is the output.
3. X=3 //Assigns
value 3 to variable X
This is also another way of assigning value to a variable.
4.Y=c(3,4,5,6) //creating vector with four values
Here, the vector name is Y. and values are 3,4,5,6. You can see the values of Y by just typing Y on the command prompt.
5. y=c(1:50)
// create a vector y containing
values 1 to 50
The above vector y contains values from 1 to 50.
i.e. z=(1,2,3) can also be written as z=c(1:3)
6.c(y,7,Y) // it will place 7 between the
results of two vectors
7.a<-sqrt a="" elements="" finding="" nbsp="" of="" root="" span="" square="" vector="" z="">-sqrt>
8. a=c(1:4) //this creates vector a with values 1,2,3,4
b=c(1,10) // this creates vector b with values 1 and 10
a+b //adding two vectors. Here elements
of one vector should be evenly distributed to other vector. i.e . vector a has 4 elements which is evenly divisible by no of values in vector b. otherwise the addition will result in an error
9. 1:20 //displays numbers from 1 to 20
10. pi:10 // displays numbers from 3.141593 to
9.141593( incr. by 1)
No comments:
Post a Comment