Question: Explain output of each line using R studio code. Problem 1. Explain what each line of the following R code do? You can run them


Problem 1. Explain what each line of the following R code do? You can run them in R and check the results. (a) x + c(1.2.3, 2, 3, 4, 8, 12, 43, -4,-1) (b) max(x) (c) y + c(x, NA) (d) max(y, nam = T) (e) x2 + c(-100,-43,0,3,1, -3) and min(x.x2) (f) sample(4:10) (s) sample(c(2.5,3), size=3, replace=FALSE) (h) sample(c(2,5.3), size=3, replace= TRUE) (i) sample(2, 10, replace = TRUE) (what happens when you write "replace = FALSE"?) () sample(1:2, size=10, prob=c(1,3), replace=TRUE) (k) round(3.14159, digits = 2) (1) range(100:400) (m) matrix(c(1.2.3, 2, 3, 4, 8, 12, 43.-4.-1,9,14), nr=3, nc=4) (n) matrix(c(1.2.3.2, 3, 4, 8, 12, 43, -4,-1,9,14), nr=3, nc=4, byrow = T) (o) - matrix(c(4.3.4,6,7,6),3,2), rownames(x) + c("rowl", "row2", "row 3"), colnames(x) = c("coll", "col2") (9) x +rbind(c(1:4),c(5,8)), y cbind(c(1:4),c(5,8)) (P) y + 1:9, w 2:10, 2 3:5, and rbind(y,w.z). (r) Let m matrix(1:36,9,4). Check m[2,3] m3] m2. cbind(m[3]) m[-(3:8) 2:4). (8) Let x + cbind(xl = 3, x2 = c(4:1, 2:5)). Check diminames(x)[(1) letters 1:8] apply(x, 2, mean, trim = 2) col.sums apply(x, 2. sum) row.sums apply(x, 1, sum) apply(x, 2. sort)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
