I have a data set with values that can be represented in multi-dimensional cartesian space. e.g.:
> data = matrix(1:20, ncol = 4)
[,1] [,2] [,3] [,4]
[1,] 1 6 11 16
[2,] 2 7 12 17
[3,] 3 8 13 18
[4,] 4 9 14 19
[5,] 5 10 15 20
Each row is a data-point, and each column represents a dimension. I would like to study the direction of each data point relative to the origin, rather than their absolute distance to the origin. I would therefore like to convert the data-set into a 4-d polar coordinate space (aka hyperspherical coordinates).
If I only wanted to convert two dimensions, this could be achieved using one of the answers here. Is there a general solution that will allow conversion to n-dimensional polar space? The closest example I have found is the CoordinateTransformData function in the Wolfram language, which generates the symbolic algebra for conversion into n-dimensions.