[R-sig-Geo] How produce several maps with bubble()

Edzer Pebesma edzer.pebesma at uni-muenster.de
Thu May 24 15:16:12 CEST 2012



On 05/24/2012 03:00 PM, Gaspard Charrier wrote:
> Hi!
> 
> I am a beginner on R, especially on programming. I'm trying to produce 
> several maps by page with the bubble function of the sp package. But I 
> encounter some difficulties to customize the bubble function.
> 
> I saw that classic function like par(mfrow=) or layout() don't work with 
> lattice graphics. So, I used the split parameter to define the position 
> of each map. But as I working on many variables, this solution isn't 
> really convenient. After some research, it seems that I should use the 
> panel function inside the bubble one. But my attempts failed with an 
> error like the "argument matches multiple formal arguments".
> 
> I use the meuse dataset as example of my scheme. I show you my script, 
> maybe it could help to find where I'm wrong.
> 
> |library(sp)
> library(lattice)
> data(meuse)
> coordinates(meuse) <- ~x+y
> test<-meuse[,1:4]
> 
> for (i in 1:4)
> { carte<-bubble(test,zcol=i,fill=TRUE,maxsize=2,do.sqrt=TRUE,col=2)
> }
> 
> plot(carte, index.cond = list(rep(1,4)),
>       layout = c(2, 2),
>       panel = function(x, y, ...)
>       {
>          panel.bubble(x,y,...)
> })|
> 
> |# This gives the error:| |Error in plot.trellis(carte, index.cond = 
> list(rep(1, 4)), layout = c(2,  : argument 4 matches multiple formal 
> arguments|
> 
> So the panel function don't works well in my script, but I don't 
> understand why (I also try to change panel.bubble by panel.plot, without 
> effects).

panel is not an argument of plot (see ?plot.trellis). You want to
specify it as an argument to bubble().


> 
> As I said before, my dataset contains many variables. So I add new 
> variables to the meuse dataset to have a more relevant dataset for my 
> problem.
> 
> |meuse1<-meuse[,1:6]
> meuse1$ion1<-meuse1$cadmium
> meuse1$ion2<-meuse1$copper
> meuse1$ion3<-meuse1$lead
> meuse1$ion4<-meuse1$zinc
> meuse1$ion5<-meuse1$cadmium
> meuse1$ion6<-meuse1$copper
> meuse1$ion7<-meuse1$lead
> meuse1$ion8<-meuse1$zinc
> meuse1$ion9<-meuse1$cadmium
> meuse1$ion10<-meuse1$copper
> meuse1$ion11<-meuse1$lead
> meuse1$ion12<-meuse1$zinc
> coordinates(meuse1) <- ~x+y
> test2<-meuse1[,1:16]|
> 
> I desire to create my maps with the bubble function, with a presentation 
> of six maps by page (3 lines and 2 columns). I tried to read the code of 
> the bubble function but I'm not able to understand what are doing the 
> different lines. Do you know where I could found explanations of the 
> bubble code? Or if you have any idea to improve my script, I'll be grateful.

bubble tries to deal with all the arguments it can get. Read the
documentation of ?bubble, and try to understand all arguments. If in the
body of bubble a function is called that you don't understand, read its
documentation.

> 
> Any direction (or any documentation where I could find something to go 
> ahead) would be welcome.
> 
> 
> 
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

-- 
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster
Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251
8333081, Fax: +49 251 8339763  http://ifgi.uni-muenster.de
http://www.52north.org/geostatistics      e.pebesma at wwu.de



More information about the R-sig-Geo mailing list