0

I want to apply feature scaling technique to my dataset to scale the feature. In particular I want to use scaling to unit length technique to scale my features. I did a bit research on what packages are available for scaling. I did come across these from the internet sources, [enter link description here][1]

[1] scale in R - from one of the answers, I got to know that this scaling uses the Z score normalization technique.

Is there any package already available to implement scaling to unit length in R? I want to know if there is any package available which implements this formula ,

X` = X/(||X||).

[1]: https://stackoverflow.com/questions/20256028/understanding-scale-in-r#:~:text=scale%20%2C%20with%20default%20settings%2C%20will,divide%20by%20the%20std%20deviation.)

Luiy_coder
  • 321
  • 2
  • 11

1 Answers1

2

Something like this?

uscale <- function(x, na.rm = FALSE){
  d <- diff(range(x, na.rm = na.rm))
  (x - min(x, na.rm = na.rm))/d
}
Rui Barradas
  • 70,273
  • 8
  • 34
  • 66
  • Yes I can do the same by defining a function. Just wanted to check if there are any predefined libraries/packages like scale in R. – Luiy_coder Jun 17 '21 at 10:54
  • @Luiy_coder asking for package recommendations is off topic here. This answer shows a good solution in base R. – dww Jun 17 '21 at 11:10
  • Yes the answer is a very good solution and I do agree that! – Luiy_coder Jun 17 '21 at 11:43