Applying pnorm to columns of a data frame

前端 未结 1 810
时光取名叫无心
时光取名叫无心 2021-02-14 22:35

I\'m trying to normalize some data which I have in a data frame. I want to take each value and run it through the pnorm function along with the mean and standard deviation of th

相关标签:
1条回答
  • 2021-02-14 22:48

    You want:

    normalize <- apply(hist_data, 2, function(x) pnorm(x, mean=mean(x), sd=sd(x)))
    

    The problem is that you're passing in the individual column into pnorm, but the entire hist_data into both the mean & the sd.

    As I mentioned on twitter, I'm no stats guy so I can't answer anything about what you're actually trying to do :)

    0 讨论(0)
提交回复
热议问题