Hi: Perhaps this will do; the data were read into a data.frame object named xx.
# Melt the data - constructs a factor 'variable' whose levels are the variable names # and a numeric variable named 'value' containing, oddly enough, the numeric values. # Requires package reshape. library(reshape) library(lattice) xy <- melt(xx) # Two versions of the density plot: one with the points as a rug plot, and another without. densityplot(~ value, data = xy, groups = variable) densityplot(~ value, data = xy, groups = variable, type = 'n') # On the off chance you want a legend.... densityplot(~ value, data = xy, groups = variable, type = 'n', key = simpleKey(text = levels(xy$variable), space = 'top', columns = 2, lines = TRUE, points = FALSE)) HTH, Dennis On Mon, May 10, 2010 at 7:22 PM, Roslina Zakaria <zrosl...@yahoo.com> wrote: > > Hi r-sers, > I have a data of relative frequencies for the interval of 0-20, > 20-40,...380-400. I would like the two data on the same graph using the > same x-axis label. My question is how to get a smooth curve using kernel > density code if it possible for this data. > > > cbind(rel_obs,rel_gen) > rel_obs rel_gen > [1,] 0.000000000 0.0000 > [2,] 0.092534175 0.0712 > [3,] 0.105152471 0.1092 > [4,] 0.095688749 0.1264 > [5,] 0.107255521 0.1143 > [6,] 0.098843323 0.1063 > [7,] 0.085173502 0.0878 > [8,] 0.084121977 0.0727 > [9,] 0.064143007 0.0637 > [10,] 0.056782334 0.0475 > [11,] 0.048370137 0.0402 > [12,] 0.041009464 0.0314 > [13,] 0.021030494 0.0269 > [14,] 0.029442692 0.0235 > [15,] 0.018927445 0.0183 > [16,] 0.015772871 0.0134 > [17,] 0.009463722 0.0100 > [18,] 0.007360673 0.0089 > [19,] 0.005257624 0.0072 > [20,] 0.004206099 0.0033 > [21,] 0.004206099 0.0034 > [22,] 0.003154574 0.0030 > [23,] 0.002103049 0.0024 > [24,] 0.000000000 0.0018 > [25,] 0.000000000 0.0015 > [26,] 0.000000000 0.0019 > [27,] 0.000000000 0.0011 > [28,] 0.000000000 0.0006 > [29,] 0.000000000 0.0009 > [30,] 0.000000000 0.0006 > [31,] 0.000000000 0.0003 > [32,] 0.000000000 0.0001 > [33,] 0.000000000 0.0000 > [34,] 0.000000000 0.0001 > [35,] 0.000000000 0.0000 > [36,] 0.000000000 0.0000 > [37,] 0.000000000 0.0001 > [38,] 0.000000000 0.0000 > [39,] 0.000000000 0.0000 > [40,] 0.000000000 0.0000 > [41,] 0.000000000 0.0000 > > Thank you. > > > > > [[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. > > [[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.