Use R code to solve the following!!!
1. Set the random seed as 5206. (hint: check the set.seed
function)
Save the random seed vector to seed.(hint: use the command seed
<- .Random.seed)
2. Create a vector v1 of length 30 by sampling from 1 to 30 without
replacement.(hint: check the sample function)
3. Convert the vector v1 into a 5 x 6 matrix m1 filled by
row.
4. Calculate the L-1 norm of matrix m1 defined as the the maximum
absolute column sum of the matrix and assign it to n1.
5. Calculate the L-infinity norm of matrix m1 defined as the
maximum absolute row sum of the matrix and assign it to n2.
6. Calculate the Frobenius norm of matrix m1 defined as the square
root of the sum of the squares of its elements and assign it to
n3.
set.seed(seed = 5206)
v1 <- sample(x = 1:30,size = 30,replace = FALSE)
v1
m1<-matrix(v1,nrow = 5,ncol = 6,byrow=TRUE)
m1
n1<-max(colSums(m1))
n1
n2<-max(rowSums(m1))
n2
n3=sqrt(sum(m1*m1))
n3
Get Answers For Free
Most questions answered within 1 hours.