Class 2
Class 2
> DATE()
> dat1
> dt1
> dt1+90
> Sys.Date()
[1] "2020-09-02"
> sys.date()
> Sys.time()
>
> dt2
[1] "2020-09-02"
Types of Vectors
> a=5
> b=2
> a/b
[1] 2.5
> a^b
[1] 25
> a**b
[1] 25
> a %% b
[1] 1
> b %% a
[1] 2
> a %/% b
[1] 2
log (1)
[1] 0
> n = -1:10
>n
[1] -1 0 1 2 3 4 5 6 7 8 9 10
> n= -(1:10)
>n
[1] -1 -2 -3 -4 -5 -6 -7 -8 -9 -10
> n=6
> r=3
> choose(n,r)
[1] 20
> n=123.456789
> x= -123.456789
> floor()
[1] 123
> floor(x)
[1] -124
> ceiling(n)
[1] 124
[1] 123
> round(n)
[1] 123
[1] 123.46
[1] 123
[1] 123.5
[1] 120
[1] 100
VECTOR OPERATOR
[1] 5
[1] -1
[1] 6
[1] 0.6666667
[1] 0
[1] 2
y = seq(from = 1, to = 100, by = 2)
>y
[1] 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45
[24] 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91
[47] 93 95 97 99
> y = seq(1,100,2)
>y
[1] 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45
[24] 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91
[47] 93 95 97 99
[25] 100.000
> i = c(3,5,7,9)
> letters [i]
[1] "c" "e" "g" "i" HAVE TO MAKE A CONSTRUCT FOR THIS TO WORK
>
[1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p"
[17] "q" "r" "s" "t" "v" "w" "x" "y" "z"
> a = c(11,13,21)
> b= c(9,26,16)
[1] 1 3
>d
[1] 1 3
[1] 11 21
> x = rep(1,10)
>x
[1] 1 1 1 1 1 1 1 1 1 1
[1] 1 2 3 4 5 6 7 8 9 10
[1] TRUE
[1] FALSE
> a = c(11,13,21)
> cumsum(a)
[1] 11 24 45
> cumprod(a)
> cummmax(a)
> cummax(a)
[1] 11 13 21
> cummin(a)
[1] 11 11 11
> v= c(17,19,26,11,5,2)
> cummax(v)
[1] 17 19 26 26 26 26
> cummin(v)
[1] 17 17 17 11 5 2
> diff(v)
[1] 2 7 -15 -6 -3
[1] 80
>
[,1] [,2]
[1,] 0 0
[2,] 0 0
[3,] 0 0
[4,] 0 0
[5,] 0 0
>x
[,1] [,2]
[,1] [,2]
Warning message:
In matrix(letters, 10, 3) :
data length [26] is not a sub-multiple or multiple of the number of rows [10]
Warning message:
In matrix(letters, 14, 3) :
data length [26] is not a sub-multiple or multiple of the number of rows [14]
[,1] [,2]
[,1] [,2]
> d= matrix(5,2,2)
>d
[,1] [,2]
[1,] 5 5
[2,] 5 5
> d [1,1]
[1] 5
> d [2,1]
[1] 5
>d
Team A Team b
game 1 5 5
gaame 2 5 5
> nm
[1] "Adam"
> length(nm)
[1] 1
[1] 4
> eco
[1] 2
> nchar (eco)
[1] 4 5
>b
[1] 1
>b
>b
>