Below you will find pages that utilize the taxonomy term “R”
Posts
R lang
operators Exponent: ^ Bit: & | Conditional: && ||
difference between = and <- operators Just use =
vectors (range) everything is a vector 1:9, 1:2:9, c(1,3,2,-8.1) c() for concat vector addition v1 + v2 : element wise matrices matrix(c(1,2,3,4,5,6,7,8,9), nrow=3) nrow is the number of rows or ncol for number of columns fills in column order, i.e. [[1,4,7],[2,5,8],[3,6,9]] matrix(1:9, nrow=3, byrow=T) : fills in row order matrix multiplication m1 %*% m2 transpose t(m1) slicing m1[1,3] m1[,3] : all elements on third column m1[1,] : all elements on first rows m1[,-2] : all but the second column m1[1,1] = 15 m1[,2:3] = 1 : set columns 2 and 3 to 2 m1[,2:3] = 4:9 : set columns 2 and 3 to col2:4,5,6, col3:7,8,9 m1[m1>5] : filter elements in m1 that are greater than 5 m1[m1>5] = 3 : set all elements greater than 5 to 3 loops for(i in 1:3) { print(i) } while(sum(v1)>=5) {}