Hi all,
First off, thank you for the overwhelming response last time. I'm still
trying to figure out the syntax of R to plot some distributions of some
frequencies. I've managed to plot histograms from the data, but I would
like to clean it up using xyplot from library(lattice). Unfortunately
I cannot find a solution to my problem.
Given a dataframe "all2", with numerical data in cols "year" and "standard"
("standard" being standardized data)
>all2
Year standard
1 2001 0.034246575
2 2001 0.000000000
...
141 2008 0.012820513
142 2008 0.230769231
I have plotted separate histograms for each year using
hist(all2[Year==2001,]$standard,breaks=seq(0,.7,.005),ylim=c(0,10),main="2001",xlab="cooccured/total
sites",ylab="frequency of cooccurance")
hist(all2[Year==2002,]$standard, ...
hist(all2[Year==2003,]$standard, ...
etc.
I would like to clean it up a bit by plotting the data using xyplot from
library(lattice) of the standardized.data.
My questions are:
a. Is there a function I could use inside "xyplot" to graph the
frequency/histogram of a given year?
I tried something around the lines of,
xyplot(freq(all2[Year==2001,]$standard)~(all2[Year==2001,]$standard)|all2[Year==2001])
obviously did not work.
b. How would I plot the frequencies of standard for each year in xyplot?
I tried converting all2 into a ftable, and from there converting it into a
dataframe (freqframe) and then plotting:
xyplot(freqframe$Freq~freqframe$standard|freqframe$Year)
the plot is wrong, probably because the dataframe has unnecessary repeats of
values.
I also tried converting all2 into a ftable (also tried a matrix) and naming
the columns and rows and evoking them in the xyplot. But this has also
turned disasterous.
Thanks in advance!
--
Lanna Jin
[hidden email]
510-898-8525
[[alternative HTML version deleted]]
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide
http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.