This R code is trying to scale the matrix and transform all the

Added on - 18 Sep 2019

  • 1

    Pages

  • 135

    Words

  • 108

    Views

  • 0

    Downloads

Trusted by +2 million users,
1000+ happy students everyday
Showing pages 1 to 1 of 1 pages
This R code is trying to scale the matrix and transform all the values of the matrix instandardised values. The formula for normalising the value is (x - mean)/sdwhere x = value of the particular elementmean = mean of each columnsd = standard deviation of the column#creating a matrix with 3 columns and 3 rowsmatrix_1 = matrix(seq(1,12),ncol=4,nrow=3,byrow=TRUE)matrix_1#calling function matrix_scalem_scl <- matrix_scale(matrix_1)m_scl#function to scale values of matrixmatrix_scale <- function(x) sweep(sweep(x, 2, colMeans(x)), 2, apply(x, 2, sd), '/')
desklib-logo
You’re reading a preview
Preview Documents

To View Complete Document

Click the button to download
Subscribe to our plans

Download This Document