Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to plot skewed and normal data in r

Using hypothetical data I want to generate these three plots in one plot. enter image description here

I wonder how I can do it. Is it possible to do it using ggplot2 or fGarch packages?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Here an approach with ggplot2

library("ggplot2")

x <- 0:100
y <- c(dnorm(x, mean=50, sd=10), 
       dlnorm(x, meanlog=3, sdlog=.7), 
       dlnorm(100-x, meanlog=3, sdlog=.7))

df <- data.frame(
  x=x,
  y=y,
  type=rep(c("normal", "right skewed", "left skewed"), each=101)
)

ggplot(df, aes(x, y, color=type)) + geom_line()
     

Skewness

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading