Tutorial by Examples

Vectors a <- c(1, 2, 3) b <- c(4, 5, 6) mean_ab <- (a + b) / 2 d <- c(1, 0, 1) only_1_3 <- a[d == 1] Matrices mat <- matrix(c(1,2,3,4), nrow = 2, ncol = 2) dimnames(mat) <- list(c(), c("a", "b", "c")) mat[,] == mat Dataframes df &lt...
# Creates a 1 row - 2 columns format par(mfrow=c(1,2)) plot(rnorm(100), main = "Graph 1", ylab = "Normal distribution") grid() legend(x = 40, y = -1, legend = "A legend") plot(rnorm(100), main = "Graph 2", type = "l") abline(v = 50) Resu...
# Create 100 standard normals in a vector x <- rnorm(100, mean = 0, sd = 1) # Find the lenght of a vector length(x) # Compute the mean mean(x) # Compute the standard deviation sd(x) # Compute the median value median(x) # Compute the range (min, max) range(x) # Sum an itera...

Page 1 of 1