[R-sig-Geo] Storing Multiple spplots in List
MacQueen, Don
macqueen1 at llnl.gov
Tue Apr 17 01:38:26 CEST 2012
Please make a small reproducible example.
There is no way anyone can figure out the problem with what you have
supplied.
What is telling you they are blank?
Do your spplot() commands produce a plot when executed outside the
function?
This works for me:
tmp <- list()
length(tmp) <- 2
## I used the first example in ?spplot to do this:
tmp[[1]] <- spplot( ## args )
tmp[[2]] <- spplot( ## args )
## then I get plots from any of these:
lapply(tmp, print)
## or
print( tmp[[1]])
## or even,
print(tmp)
--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
On 4/13/12 9:01 PM, "Mike Sukmanowsky" <mike.sukmanowsky at gmail.com> wrote:
>Hi all,
>
>I have the function below where I am attempting to create a list of
>spplots
>for later use. The problem is that the list come back blank for all
>elements. Why doesn't spplot return proper plots that could be used via
>print()?
>Please see the assignment to the plots list below - plots[[letter]] <-
>spplot()
>
>
>plotFSAs <- function(spatialData, field) {
>plots <- list()
>colours <- brewer.pal(8, "Greens")
> for(letter in LETTERS) {
>inLetter <- substr(spatialData at data$CENSUS_FSA, 1, 1) %in% letter
>fsa.spatial <- subset(spatialData, inLetter)
> classes <- classIntervals(fsa.spatial at data[,c(field)], length(colours),
>style="equal")
> plots[[letter]] <- spplot(fsa.spatial,
>field,
>col.regions=colours,
>at=classes$brks,
>col="black",
>lwd=0.8,
>main=paste("FSAs Beginning with ", letter),
>cex.main=0.3,
>colorkey=list(
>labels = list(
>at=classes$brks,
>labels=round(classes$brks, 2)
>)
>)
>)
>}
>return(plots)
>}
>
>
>--
>Mike Sukmanowsky
>
> [[alternative HTML version deleted]]
>
>_______________________________________________
>R-sig-Geo mailing list
>R-sig-Geo at r-project.org
>https://stat.ethz.ch/mailman/listinfo/r-sig-geo
More information about the R-sig-Geo
mailing list