0

Just one question about r. as we know ,in the base R, for example, in hist function, we conduct following calculation:

x=rnorm(500,90,3)
a<-hist(x)
b<-density(x)

then we can find details by a$ or b$ for some calculation details. But in ggplot2, for example, when we use stat_density, stat_density2d etc. the calculation is also done in the back. how to cite these details ? if use str(p) (p is the ggplot object), we can only get some mapping etc. information.

So, how to get calculation details in a ggplot way? thanks.

  • You can do this as indicated by the duplicated, but in general it's probably a good idea to avoid it. Use ggplot just for plotting. If you need the details of a model, you should fit the model yourself and then extract the values you need to plot. ggplot isn't optimized to be used for analysis, just visualization. – MrFlick Apr 14 '20 at 03:31
  • thanks ! the reason I ask this is when we use ggplot2, for example, we want to aes some computed values into color, or fill , or even do some further calculation from them then conduct the aes, it is not so convenient ... – Guangming Wu Apr 14 '20 at 03:56

0 Answers0