EPPS 6323: Lab01 R programming basics I

Author

Cristina Rivera”

R Programming Basic Commands

Create object using the assignment operator (<-, =)

[1] 1 3 2 5
[1] 1 6 2

Using function

[1] 3
[1] 3

Using +, -, *, /,^ operators

[1]  2 10  5
[1] "x" "y"
character(0)

Matrix operations

     [,1] [,2]
[1,]    1    3
[2,]    2    4
     [,1] [,2]
[1,]    1    2
[2,]    3    4
         [,1]     [,2]
[1,] 1.000000 1.732051
[2,] 1.414214 2.000000
     [,1] [,2]
[1,]    1    3
[2,]    2    4
     [,1] [,2]
[1,]    1    9
[2,]    4   16
[1] 0.9941678
 [1] -1.1439763145  1.3421293656  2.1853904757  0.5363925179  0.0631929665
 [6]  0.5022344825 -0.0004167247  0.5658198405 -0.5725226890 -1.1102250073
[11] -0.0486871234 -0.6956562176  0.8289174803  0.2066528551 -0.2356745091
[16] -0.5563104914 -0.3647543571  0.8623550343 -0.6307715354  0.3136021252
[21] -0.9314953177  0.8238676185  0.5233707021  0.7069214120  0.4202043256
[26] -0.2690521547 -1.5103172999 -0.6902124766 -0.1434719524 -1.0135274099
[31]  1.5732737361  0.0127465055  0.8726470499  0.4220661905 -0.0188157917
[36]  2.6157489689 -0.6931401748 -0.2663217810 -0.7206364412  1.3677342065
[41]  0.2640073322  0.6321868074 -1.3306509858  0.0268888182  1.0406363208
[46]  1.3120237985 -0.0300020767 -0.2500257125  0.0234144857  1.6598706557

Simple descriptive statistics (base)

[1] 0.01103557
[1] 0.7328675
[1] 0.8560768
[1] 0.8560768

Visualization using R Graphics (without packages)

quartz_off_screen 
                2 
 [1]  1  2  3  4  5  6  7  8  9 10
 [1]  1  2  3  4  5  6  7  8  9 10