histogram(~ standard | Year, data = all2)
2009/11/7 Lanna Jin <lannajin at gmail.com>:> 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
>
> lannajin at gmail.com
> 510-898-8525
>
> ? ? ? ?[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
>
--
Felix Andrews / ???
Postdoctoral Fellow
Integrated Catchment Assessment and Management (iCAM) Centre
Fenner School of Environment and Society [Bldg 48a]
The Australian National University
Canberra ACT 0200 Australia
M: +61 410 400 963
T: + 61 2 6125 4670
E: felix.andrews at anu.edu.au
CRICOS Provider No. 00120C
--
http://www.neurofractal.org/felix/