Sunday, August 2, 2015

Programming with R: Part-1

Posted by   on

R Codes
Press Enter on your keyboard to execute. 
Code Purpose
2+2 Add 2 with 2
1:10 Get values 1 thru 10
201:300 Get values 201 thru 300
a=2 Assign value of a to 2.
Note: This does not mean a is equal to 2. That purpose is met by a==2.
a Know assigned value of a
b=3 Assign value of b to 2.
a*b Multiply a with b
a^b a to the power b
log(a) Log of a
Note: By default log is natural i.e. with base e which we call ln. That is the code log(2) is tantamount to ln(2).
Keep in mind that ln(2) is unavailable in R.
log(2) Log of 2
exp(1) e to the power 1.
?log Get help about log.
To get other help topics, type similarly like ?sum
log (x, base=7) Usual format for value of log (x) with base 7
log (base=10, x=a) Detail format of log
log (a,10) Shortcut format for log
choose (12, 8) Number of possible combinations of taking 8 object out of 12. That is, it’s analogous to 12C8
gamma(5) Value of Γ5 that is, 4!
factorial (8) 8! i.e. 8 factorial
exp (2.3) e2.3
sqrt (8.4) Square root of 9.4
beta (2,3)
B(a,b) = Γ(a)Γ(b)/Γ(a+b).
round(2.34) Rounding
round(2.34567, 4) Rounding up to 4 decimal
pi 3.1416… i.e. value of π
abs (-2) Absolute value of (-2)
class (b) See the type of object b
class (log) See class of log
sqrt (beta(7,9)) Square root of this beta value
log(17) +1 Same as code
Courtesy: Dr. Jafor Ahmed Khan
Profesor, Dept. of Statistics, Biostatistics & Informatics, University of Dhaka

No comments:
Write comments

Hey, we've a very popular astronomy portal in Bangla language. If You know Bangla, You'll like it - sky.bishwo.com
Join Our Newsletter