[R] Histogram plots in Lattice with spatialgrid dataframe data

Thomas Adams tea3rd at gmail.com
Sun Jul 9 17:21:13 CEST 2017


Hi all,

I can not seem to get what I want using the Lattice package to generate an
array of histograms of
spatialgrid dataframe data.

I can use the sp package and spplot to generate an array of maps that
display an array of spatialgrid dataframe data -- that's good. I have:

spplot(ann_bias,xlim=c(1423987.5,2614612.5),ylim=c(-5862637.5,-4624387.5),at=brks,col.regions=colp(length(brks)-1),main="NOAA/NWS
OHRFC Stage-3/MPE Precipitation Estimate Bias with respect to PRISM\n1997 -
2016")

Which works... I can also do histogram(ann_bias$bias1997), which works too.
I have also created a 'time-series' of boxplots successfully with these
data as well...

But if I try:

year<-c('1997','1998','1999','2000','2001','2002','2003','2004','2005','2006','2007','2008','2009','2010','2011','2012','2013','2014','2015','2016')
dat<-c(ann_bias$bias1997,ann_bias$bias1998,ann_bias$bias1999,ann_bias$bias2000,ann_bias$bias2001,ann_bias$bias2002,ann_bias$bias2003,ann_bias$bias2004,ann_bias$bias2005,ann_bias$bias2006,ann_bias$bias2007,ann_bias$bias2008,ann_bias$bias2009,ann_bias$bias2010,ann_bias$bias2011,ann_bias$bias2012,ann_bias$bias2013,ann_bias$bias2014,ann_bias$bias2015,ann_bias$bias2016)

> data<-data.frame(year=c(year),bias=c(dat))
> histogram(~ bias | year, data=data)

I get a lattice plot of histograms, where the years vary, but all the
histograms are identical, which I know they should not be. It seem that all
the data from the combined spatialgrid dataframes are being used and
repeated.

Obviously, I'm not constructing the data correctly. Can someone tell me
what I doing wrong. I've poured over this for a solid day, now...

Regards,
Tom

	[[alternative HTML version deleted]]



More information about the R-help mailing list