Ex 3
Ex 3
> print(a)
> print(b)
> print(c)
> print(d)
+ print(e)
"print(e)
f <- 'Single"
> print(f)
> print(g)
>
>
> print(paste(a,b,c))
>
> print(result)
[1] "23.1234568"
> # The minimum number of digits to the right of the decimal point.
> print(result)
[1] "23.47000"
> print(result)
[1] "6"
> # Numbers are padded with blank in the beginning for width.
> print(result)
> print(result)
> print(result)
>
>
>
> print(result)
[1] 30
>
> print(result)
>
>
>
> print(result)
[1] "act"
>
>
> print("abc");
[1] "abc"
> print(12.5)
[1] 12.5
> print(63L)
[1] 63
> print(TRUE)
[1] TRUE
> print(2+3i)
[1] 2+3i
[1] 68 65 6c 6c 6f
>
>
> print(v)
[1] 5 6 7 8 9 10 11 12 13
> print(v)
> # If the final element specified does not belong to the sequence then it is disca
> print(v)
>
>
[1] 5.0 5.4 5.8 6.2 6.6 7.0 7.4 7.8 8.2 8.6 9.0
>
>
> print(s)
>
>
> print(u)
> print(v)
> print(x)
> print(y)
[1] "Sun"
>
>
>
> print(add.result)
[1] 7 19 4 13 1 13
> print(sub.result)
[1] -1 -3 4 -3 -1 9
[1] 12 88 0 40 0 22
> print(divi.result)
>
>
>
> print(add.result)
[1] 7 19 8 16 4 22
>
>
> print(sub.result)
[1] -1 -3 0 -6 -4 0
>
>
> print(sort.result)
[1] -9 0 3 4 5 8 11 304
> print(revsort.result)
[1] 304 11 8 5 4 3 0 -9
> # Sor ng character vectors.
> print(sort.result)
> print(revsort.result)
>
>
>
> # values.
> print(list_data)
[[1]]
[1] "Red"
[[2]]
[1] "Green"
[[3]]
[1] 21 32 11
[[4]]
[1] TRUE
[[5]]
[1] 51.23
[[6]]
[1] 119.1
>
>
+ list("green",12.3))
> print(list_data)
$`1st Quarter`
$A_Matrix
[1,] 3 5 -2
[2,] 9 1 8
[1] "green"
[1] 12.3
>
>
+ list("green",12.3))
>
>
>
> print(list_data[1])
$`1st Quarter`
> # Access the thrid element. As it is also a list, all its elements will be printe
> print(list_data[3])
[1] "green"
[1] 12.3
> # Access the list element using the name of the element.
> print(list_data$A_Matrix)
[1,] 3 5 -2
[2,] 9 1 8
>
>
>
+ list("green",12.3))
> print(list_data[4])
$<NA>
NULL
> print(list_data[3])
>
>
> print(merged.list)
[[1]]
[1] 1
[[2]]
[1] 2
[[3]]
[1] 3
[[4]]
[1] "Sun"
[[5]]
[1] "Mon"
[[6]]
[1] "Tue"
>
>
> print(list1)
[[1]]
[1] 1 2 3 4 5
> print(list2)
[[1]]
[1] 10 11 12 13 14
[1] 1 2 3 4 5
> print(v2)
[1] 10 11 12 13 14
> print(result)
[1] 11 13 15 17 19
>
>
>
> print(M)
[1,] 3 4 5
[2,] 6 7 8
[3,] 9 10 11
[4,] 12 13 14
> print(N)
[1,] 3 7 11
[2,] 4 8 12
[3,] 5 9 13
[4,] 6 10 14
row1 3 4 5
row2 6 7 8
row3 9 10 11
row4 12 13 14
>
>
> print(P[1,3])
[1] 5
> print(P[4,2])
[1] 13
> print(P[2,])
6 7 8
> print(P[,3])
5 8 11 14
>
>
[1,] 3 -1 2
[2,] 9 4 6
> print(matrix2)
[1,] 5 0 3
[2,] 2 9 4
Result of addi on
> print(result)
[1,] 8 -1 5
[2,] 11 13 10
Result of subtrac on
> print(result)
[1,] -2 -1 -1
[2,] 7 -5 2
>
>
>
>
[1,] 3 -1 2
[2,] 9 4 6
> print(matrix2)
[1,] 5 0 3
[2,] 2 9 4
> print(result)
[1,] 15 0 6
[2,] 18 36 24
Result of division
> print(result)
>
>
>
> print(result)
,,1
[1,] 5 10 13
[2,] 9 11 14
[3,] 3 12 15
,,2
[1,] 5 10 13
[2,] 9 11 14
[3,] 3 12 15
>
>
+ matrix.names))
matrix.names"
> print(result)
,,1
[1,] 5 10 13
[2,] 9 11 14
[3,] 3 12 15
,,2
[1,] 5 10 13
[2,] 9 11 14
[3,] 3 12 15
>
>
+ column.names, matrix.names))
> # Print the third row of the second matrix of the array.
> print(result[3,,2])
3 12 15
> # Print the element in the 1st row and 3rd column of the 1st matrix.
> print(result[1,3,1])
[1] 13
> print(result[,,2])
ROW1 5 10 13
ROW2 9 11 14
ROW3 3 12 15
>
>
>
> print(result)
[1,] 10 20 26
[2,] 18 22 28
[3,] 6 24 30
>
>
>
> print(new.array)
,,1
[1,] 5 10 13
[2,] 9 11 14
[3,] 3 12 15
,,2
[1,] 5 10 13
[2,] 9 11 14
[3,] 3 12 15
> # Use apply to calculate the sum of the rows across all the matrices.
> print(result)
[1] 56 68 60
>
>
>