Hello All,* *I want to draw a histogram with density curve. *
*For that simply i created a data called*"x" *and i used the function called * hist(x, col = "blue", freq = FALSE),** *from this function i got a histogram*. *After that , i tried this function* ** lines(density(x), col = "red", lwd = 2 ) *but i could not get the density curve. So, Again i used other function* curve(dnorm, col = 2, add = TRUE)** *instead of the previous function for density curve. but still am getting error in R like this: Error in plot.xy(xy.coords(x, y), type = type, ...) plot.new has not been called yet" * I have used below codes to have a data and histogram with density curve" x <- rnorm(200) hist(x, col = "blue", freq = FALSE) lines(density(x), col = "red", lwd = 2) * or * x <- rnorm(200); hist(x, freq = FALSE, col = "grey"); curve(dnorm, col = 2, add = TRUE) * please give your valuable inputs Thanks in advance... -- *Best Regards, Reka. * [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.