coding basics:

finding help: Help window and search for “mean”

install.packages ("circlize")
library ("circlize") #how to load a package click run
set.seed(123)
mat = matrix(sample(1:100, 18, replace = TRUE), 3, 6)
rownames(mat) = letters[1:3]
colnames(mat) = LETTERS[1:6]

### basic settings
par(mfrow = c(3, 2))
par(mar = c(1, 1, 1, 1))

chordDiagram(mat)
circos.clear()

circos.par(gap.degree = c(rep(2, nrow(mat)-1), 10, rep(2, ncol(mat)-1), 10))
chordDiagram(mat)
circos.clear()

circos.par(start.degree = 90)
chordDiagram(mat)
circos.clear()

chordDiagram(mat, order = c("A", "B", "a", "C", "D", "b", "E", "F", "c"))

chordDiagram(mat, directional = TRUE)
chordDiagram(mat, directional = TRUE, diffHeight = 0.06)

circos.clear()

################ example 2 ###############################
set.seed(123)
mat = matrix(sample(1:100, 18, replace = TRUE), 3, 6)
rownames(mat) = letters[1:3]
colnames(mat) = LETTERS[1:6]


### colors settings
rand_color = function(n, alpha = 1) {
    return(rgb(runif(n), runif(n), runif(n), alpha = alpha))
}

par(mfrow = c(3, 3))
par(mar = c(1, 1, 1, 1))
grid.col = NULL
grid.col[letters[1:3]] = c("red", "green", "blue")
grid.col[LETTERS[1:6]] = "grey"
chordDiagram(mat, grid.col = grid.col)
chordDiagram(mat, grid.col = grid.col, transparency = 0.5)
col_mat = rand_color(length(mat), alpha = 0.5)
dim(col_mat) = dim(mat)
chordDiagram(mat, grid.col = grid.col, col = col_mat)
chordDiagram(mat, grid.col = grid.col,
    col = colorRamp2(quantile(mat, seq(0, 1, by = 0.1)),
                     rev(heat.colors(11))), transparency = 0.5)

chordDiagram(mat, grid.col = grid.col, row.col = 1:3, transparency = 0.5)
chordDiagram(mat, grid.col = grid.col, column.col = 1:6, transparency = 0.5)
chordDiagram(mat, grid.col = grid.col, row.col = c("#FF000080", "#00FF0010", "#0000FF10"))
circos.clear()


#we deleted the ", the minus and the spaces between my data
mydata <- rnorm(100, mean = 0, sd = 1)
data.mean <- mean(mydata)
data.mean # Print the value of data.mean
## [1] -0.003076955

Creating vectors:

batman<-20
superman<-10
mixed<-c(batman, superman)
mixed
## [1] 20 10
#question 4

question 5

celsius <- c(17 ,21 ,18 ,21 ,14) 
fahrenheit <- celsius *9/5 + 32
fahrenheit
## [1] 62.6 69.8 64.4 69.8 57.2

question 6

a <- seq(from = 10, to = 50, by = 10)
b <- seq(from = 12, to = 14, by = 1)
c <- seq(from = 97, to = 137, by = 10)

final <- c (a, b, c)
final
##  [1]  10  20  30  40  50  12  13  14  97 107 117 127 137

question 7

rep(1:5, each = 2, times = 2)
##  [1] 1 1 2 2 3 3 4 4 5 5 1 1 2 2 3 3 4 4 5 5

question 8

a <- seq(from = 1, to = 10, by = 1)
squares <- a^2
squares
##  [1]   1   4   9  16  25  36  49  64  81 100
mean(squares)
## [1] 38.5
median(squares)
## [1] 30.5

Sampling Data and Descriptive Statistics

Question 9

normal.samp <-  rnorm(50, mean = 30, sd = 5)
normal.samp
##  [1] 24.31977 35.57763 33.76261 26.53766 34.24919 22.03331 37.70412
##  [8] 46.39708 27.94941 32.33834 33.25904 36.43765 24.80625 33.98182
## [15] 38.08659 27.19818 25.73394 31.14077 24.81628 37.33287 32.23367
## [22] 27.79545 30.01957 35.57907 37.78089 15.86740 33.57190 26.59613
## [29] 29.94045 20.63804 26.59845 39.67853 28.60232 30.05890 34.78857
## [36] 21.84354 35.49354 32.80471 23.88351 29.68100 32.98873 26.72659
## [43] 29.44618 30.31089 19.68987 36.74066 34.96306 33.28746 26.97975
## [50] 32.29443

Question 10

min(normal.samp)
## [1] 15.8674
max(normal.samp)
## [1] 46.39708
runif (25, min=21.99232 , max = 46.2052)
##  [1] 29.04144 43.78135 40.33146 42.53120 35.28358 22.89214 45.88126
##  [8] 40.51062 35.61529 45.54123 32.92130 24.75699 30.32487 39.24129
## [15] 44.25922 29.55289 27.88515 45.56325 44.02244 23.20671 23.19473
## [22] 35.09514 41.48117 33.87327 29.43773

Question 11

rnorm(100 , mean = 0, sd = 1) 
##   [1] -0.999615004 -1.277685754 -0.163228657 -0.191343649  0.896999987
##   [6]  0.293626303 -0.484837432  0.224091817  0.949161938 -1.342107961
##  [11] -0.968359083  1.569695435  0.457174846  0.315691637 -1.080574150
##  [16] -0.755305233  0.311391380 -1.765024020 -1.309146535  1.257647431
##  [21] -0.102743856  0.624925646 -0.701628902  0.596967998 -0.453295031
##  [26] -1.194989073  0.845945113  0.236280398  2.295097798 -0.592311428
##  [31] -0.734855363  0.863774257 -1.752011812  0.001937284  1.026726646
##  [36]  0.002540859 -0.651659169  1.318964806  0.568338219 -0.433261810
##  [41]  0.622596888 -0.289984636  0.080143680 -0.705812796  1.517507354
##  [46] -0.887102110 -0.321107103 -0.303857158  0.714523438  0.831179966
##  [51]  0.529109170  0.123574343 -0.263523299  0.910987026 -1.081614034
##  [56] -0.808219502 -1.246222371 -0.229229667 -0.862184784  0.470131519
##  [61] -0.123683490  0.238162268  0.542103542 -1.586157285 -1.113199398
##  [66]  1.979237152  1.762246692  0.904215168  3.063960514  0.043477024
##  [71]  0.603745477 -0.175998885  1.468588922  0.796650352  0.713663577
##  [76] -1.015426932 -0.780391986 -0.753437209 -1.509541731 -0.218258044
##  [81] -0.018815972 -0.490493599  1.182334864 -0.746644986 -0.724955883
##  [86]  2.333990177  0.103059977  0.809380685 -1.094289274  0.163778696
##  [91]  0.423488363  0.238339676  0.579699101  0.447000014  0.626917869
##  [96] -0.718147810  0.105565672 -0.590916746 -0.533211053  0.207992924
runif (100, min=0 , max = 10) 
##   [1] 1.1857555 9.9817238 2.1886438 5.0901349 3.1316186 6.7383486 2.5761745
##   [8] 8.0827708 9.7946126 7.2058402 7.7093975 3.8990060 3.3688837 8.0867962
##  [15] 0.4131971 9.7460928 1.0108710 3.1767600 2.5268789 0.2606342 7.7888228
##  [22] 2.9197604 4.5422577 5.1648255 7.9825465 9.2964519 8.7340526 3.2100372
##  [29] 3.6431532 3.8108274 6.7450981 0.4952194 1.1940367 4.1360692 9.4074537
##  [36] 7.3301123 3.8482014 1.1479443 5.7765550 0.4115933 5.0747782 2.9650570
##  [43] 7.4922331 7.9067735 2.9978377 7.7308038 0.3322522 9.4896776 8.9932425
##  [50] 5.3220006 9.1737650 4.2441538 5.4952031 4.2597134 4.8553964 3.9572889
##  [57] 4.4668361 8.0123140 3.6279371 5.4900376 0.4492202 6.9829933 5.1716438
##  [64] 1.8007728 3.6034071 9.0994303 9.2611042 2.1486510 3.0168720 1.1498917
##  [71] 3.2500667 2.0809384 3.7871727 7.7777162 0.1784647 4.4695390 6.1533691
##  [78] 4.9334481 7.7344524 9.7154400 7.6213012 4.3889280 4.3317986 2.6912915
##  [85] 8.8841516 7.6362898 9.0319227 3.8811807 4.2945279 4.7064648 8.5768505
##  [92] 1.9771573 6.1502612 3.8811282 0.9015941 5.8771150 3.4415108 2.0978225
##  [99] 0.3880289 1.3799295