Normalisation of a two column data using min and max values

前端 未结 2 1974
旧巷少年郎
旧巷少年郎 2021-01-22 11:18

I am trying to find an R code for normalisation of my values using min and max value for a two column matrix.

My matrix looks like this: Column one (C1) and C2 I.D not

2条回答
  •  余生分开走
    2021-01-22 11:25

    This is a type of non-parametric normalisation, but I would advise you to use another method: calculate the median and interquartile range, subtract the median and divide by the IQR. This will give you a distribution with median 0 and IQR 1.

    m <- median( df$C3, na.rm = T )
    iqr <- IQR( df$C3, na.rm = T )
    df$C3 <- ( df$C3 - m ) / iqr
    

    The method that you propose is extremely sensitive to outliers. If you really want to do it, this is how:

     rng <- range( df$C3, na.rm = T )
     df$C3 <- ( df$C3 - rng[1] ) / ( rng[2] - rng[1] )
    

提交回复
热议问题