I need to scale my dataframe, I want to perform clustering. I used scale() function and it did well, but it turns my dataset into a matrix. when I want to use ggplot to show clustering on some variables, ggplot does not accept the scaled data, because i think it's a matrix. now i tried to use as.dataframe() to turn the scaled dataset back to dataframe, but all the variables from header row, are not shifted to column 1 and instead of them there are some Var1, Var2, Var3,..... is there a way that i can scale my dataframe without chaning anything, i want my dataframe look exactly the same after scaling.
Asked
Active
Viewed 32 times
0
-
Making use of `dplyr` you could do e.g. `mutate(mtcars, across(everything(), scale))` – stefan Jun 03 '21 at 08:20
-
1thank you man, you really helped me. – DataScience Jun 03 '21 at 10:28