gianni lavaredo
2012-Jun-15 15:52 UTC
[R] some help to improve "hist to plot relative frequencies"
Dear Researches, sorry for disturb. I wish to improve my figure in R plotting the relative frequencies of my data set. library(lattice) a <- c(0,0,0,1,1,2,4,5,6,7,7,7,7,7,8,8,8,8,9,9,9,9,10,10,11) histogram(a, xlab="myData") what i wish to do is: 1) invert the order of X and Y (eg: Precent of Total on X-axis and "MyData" on X-axis) 2) plot not the bar of histogram but a line (i tried with "lines(density(a))" but the result is not what i wish) Great Thanks for any helps Gianni [[alternative HTML version deleted]]
Deepayan Sarkar
2012-Jun-18 11:53 UTC
[R] some help to improve "hist to plot relative frequencies"
On Fri, Jun 15, 2012 at 9:22 PM, gianni lavaredo <gianni.lavaredo at gmail.com> wrote:> Dear Researches, > > sorry for disturb. I wish to improve my figure in R plotting the relative > frequencies of my data set. > > library(lattice) > a <- c(0,0,0,1,1,2,4,5,6,7,7,7,7,7,8,8,8,8,9,9,9,9,10,10,11) > histogram(a, xlab="myData") > > what i wish to do is: > > 1) invert the order of X and Y (eg: Precent of Total on X-axis and "MyData" > on X-axis) > 2) plot not the bar of histogram but a line (i tried with > "lines(density(a))" but the result is not what i wish)Take your pick: ta <- table(a) dotplot(ta, type = "h", lwd = 2, origin = 0) dotplot(100 * prop.table(ta), type = "h", lwd = 2, origin = 0, xlab = "Percent of total") xyplot(as.numeric(names(ta)) ~ 100 * prop.table(ta), type = "h", lwd = 2, origin = 0, horizontal = TRUE, xlab = "Percent of total", ylab = "myData", xlim = c(-1, NA)) -Deepayan