Thursday, October 20, 2011

R - Cheat sheet - Basic operations

Return to the R Cheat sheet main index

> # this is a comment line
>2+3
> 2 - 3 
> log(10) # Natural log
> 3^3 # raising to the power of three
> (2*3)+6 
> sqrt(81)
> exp(4) # exponent function


Complex numbers
Re(x) - the Real part of an imaginary number.
Im(x) - the imaginary component of an imaginary number.

> # assign an imaginary number to x
> x <-8+2i
> Re(x)
[1] 8
> Im(x)
[1] 2

Trig
cos(x)
sin(x)
tan(x)
acos(x)
asin(x)
atan(x)
atan2(y, x)
Angles are in radians, not degrees (90deg is π/2).






No comments:

Post a Comment