[R-sig-Geo] R-sig-Geo Digest, Vol 129, Issue 6

Marcel Belmont belmont161 at gmail.com
Tue May 13 04:16:11 CEST 2014


Hi All,
       I've been looking at the lattice help section and on the web
for some assistance regarding putting my 'months' label in
chronological order on my graph but failed. Presently they are
displayed in alphabetical order when I use this script:-
require(latticeExtra)
require (lattice)
data(seychelles)
z <- read.csv("C:/Users/User/Desktop/Weather Scripts/seychelles.csv",
header = TRUE)

tempatures <- xyplot(min.temp + max.temp ~ day | month,
               data = z, type = "l", layout = c(3, 1))
rainfall <- xyplot(precip ~ day | month, data = z, type = "h", lwd = 4)

doubleYScale(tempatures, rainfall, style1 = 0, style2 = 3, add.ylab2 = TRUE,
   text = c("Min. T", "Max. T", "Rain"), columns = 3)

Any help would be much appreciated. Thanks.

M.Belmont

On 06/05/2014, r-sig-geo-request at r-project.org
<r-sig-geo-request at r-project.org> wrote:
> Send R-sig-Geo mailing list submissions to
> 	r-sig-geo at r-project.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> 	https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> or, via email, send a message with subject or body 'help' to
> 	r-sig-geo-request at r-project.org
>
> You can reach the person managing the list at
> 	r-sig-geo-owner at r-project.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of R-sig-Geo digest..."
>
>
> Today's Topics:
>
>    1. Re: reading CRU files in .dat format into a data frame
>       (Remi Genevest)
>    2. Re: Export matrix weights to excel. (Rolando Valdez)
>    3. Re: Export matrix weights to excel. (Roger Bivand)
>    4. Re: BYM model in R-INLA - how to specify priors individually
>       (VIRGILIO GOMEZ RUBIO)
>    5. Decision tree classification of satellite image in R
>       (Anusheema Chakraborty)
>    6. Re: BYM model in R-INLA - how to specify priors individually
>       (James Rooney)
>    7. lAGRANGE MULTIPLIER Test and error in listw object (az14)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Mon, 5 May 2014 04:07:21 -0700 (PDT)
> From: Remi Genevest <rgenevest at free.fr>
> To: r-sig-geo at r-project.org
> Subject: Re: [R-sig-Geo] reading CRU files in .dat format into a data
> 	frame
> Message-ID: <1399288041706-7586334.post at n2.nabble.com>
> Content-Type: text/plain; charset=us-ascii
>
> Well, thanks for this advice, but actually I already read this page.
> What I was looking for is close to the issue proposed in this post by
> Lionel
> :
> http://r-sig-geo.2731867.n2.nabble.com/Turning-SpatialPointsDataFrame-to-Raster-using-rasterize-td7582452.html
>
>
>
>
>
>
> --
> View this message in context:
> http://r-sig-geo.2731867.n2.nabble.com/reading-CRU-files-in-dat-format-into-a-data-frame-tp7586327p7586334.html
> Sent from the R-sig-geo mailing list archive at Nabble.com.
>
>
>
> ------------------------------
>
> Message: 2
> Date: Mon, 5 May 2014 12:20:39 -0500
> From: Rolando Valdez <rvaldezr at gmail.com>
> To: r-sig-geo at r-project.org
> Subject: Re: [R-sig-Geo] Export matrix weights to excel.
> Message-ID: <989767EB-4AFB-4A1D-83D1-2697A36A4928 at gmail.com>
> Content-Type: text/plain; charset=windows-1252
>
> Yes, I got it.
>
> Now, I saw an issue in the matrix, I?ve got two regions with value 1 inside
> the matrix, if it is W style, how is it possible?. The rest of rows are
> standardized.
>
> Another question, the output follow the order of regions of the shape file,
> isn?t?
>
> Thank you
> El 04/05/2014, a las 12:46, Roger Bivand <Roger.Bivand at nhh.no> escribi?:
>
>> On Sat, 3 May 2014, Rolando Valdez wrote:
>>
>>> Hello,
>>>
>>> I'm working with a matrix weights, I want to know if I can export the
>>> output, to handle with excel.
>>>
>>> This is a part what I have:
>>>
>>>> zm <- readOGR(".", "zmdis?)
>>> OGR data source with driver: ESRI Shapefile
>>> Source: ".", layer: "zmdis"
>>> with 56 features and 8 fields
>>> Feature type: wkbPolygon with 2 dimensions
>>>> mapaxy = coordinates(zm)
>>>> wdist100 = dnearneigh(mapaxy, d1=0, d2=100000)
>>>> l100 = nb2listw(wdist100, style="W", zero.policy=T)
>>>> summary(l100, zero.policy=T)
>>> Characteristics of weights list object:
>>> Neighbour list object:
>>> Number of regions: 56
>>> Number of nonzero links: 86
>>> Percentage nonzero weights: 2.742347
>>> Average number of links: 1.535714
>>> 21 regions with no links:
>>> 3 6 11 13 14 15 16 24 25 27 28 35 36 38 41 47 48 51 52 53 54
>>> Link number distribution:
>>>
>>> 0  1  2  3  4  5  8
>>> 21 12 11  2  7  2  1
>>> 12 least connected regions:
>>> 1 5 7 17 19 20 21 30 33 34 45 55 with 1 link
>>> 1 most connected region:
>>> 37 with 8 links
>>>
>>> Weights style: W
>>> Weights constants summary:
>>>  n   nn S0       S1    S2
>>> W 35 1225 35 39.26667 147.3
>>>
>>> I want to get a matrix [56 x 56] to work in excel with it.
>>
>> ?listw2mat should help, then write the matrix in a form that Excel can
>> read. But note that your distance criterion leaves 21 of 56 observations
>> with no neighbours.
>>
>> Hope this helps,
>>
>> Roger
>>
>>>
>>> Thank you in advance.
>>>
>>> Rolando Valdez
>>>
>>> _______________________________________________
>>> R-sig-Geo mailing list
>>> R-sig-Geo at r-project.org
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>>
>>
>> --
>> Roger Bivand
>> Department of Economics, Norwegian School of Economics,
>> Helleveien 30, N-5045 Bergen, Norway.
>> voice: +47 55 95 93 55; fax +47 55 95 91 00
>> e-mail: Roger.Bivand at nhh.no
>
> Rolando Valdez
>
>
>
> ------------------------------
>
> Message: 3
> Date: Mon, 5 May 2014 19:51:16 +0200
> From: Roger Bivand <Roger.Bivand at nhh.no>
> To: Rolando Valdez <rvaldezr at gmail.com>
> Cc: r-sig-geo at r-project.org
> Subject: Re: [R-sig-Geo] Export matrix weights to excel.
> Message-ID: <alpine.LRH.2.03.1405051946520.16499 at reclus.nhh.no>
> Content-Type: text/plain; charset="windows-1252"; Format="flowed"
>
> On Mon, 5 May 2014, Rolando Valdez wrote:
>
>> Yes, I got it.
>>
>> Now, I saw an issue in the matrix, I?ve got two regions with value 1
>> inside the matrix, if it is W style, how is it possible?. The rest of
>> rows are standardized.
>
> You can "see" it, nobody else can. Are all the rowSums() of the matrix 1?
> If so, two of the observations only have one neighbour (maybe a pair
> linked only to each other). Why would this be unexpected if you are using
> distance-based neighbours?
>
>>
>> Another question, the output follow the order of regions of the shape
>> file, isn?t?
>
> They follow the order of the coordinate matrix you passed to dnearneigh(),
> but you can check this easily enough.
>
> Please do read the documentation, none of this is particularly difficult.
>
> Roger
>
>>
>> Thank you
>> El 04/05/2014, a las 12:46, Roger Bivand <Roger.Bivand at nhh.no> escribi?:
>>
>>> On Sat, 3 May 2014, Rolando Valdez wrote:
>>>
>>>> Hello,
>>>>
>>>> I'm working with a matrix weights, I want to know if I can export the
>>>> output, to handle with excel.
>>>>
>>>> This is a part what I have:
>>>>
>>>>> zm <- readOGR(".", "zmdis?)
>>>> OGR data source with driver: ESRI Shapefile
>>>> Source: ".", layer: "zmdis"
>>>> with 56 features and 8 fields
>>>> Feature type: wkbPolygon with 2 dimensions
>>>>> mapaxy = coordinates(zm)
>>>>> wdist100 = dnearneigh(mapaxy, d1=0, d2=100000)
>>>>> l100 = nb2listw(wdist100, style="W", zero.policy=T)
>>>>> summary(l100, zero.policy=T)
>>>> Characteristics of weights list object:
>>>> Neighbour list object:
>>>> Number of regions: 56
>>>> Number of nonzero links: 86
>>>> Percentage nonzero weights: 2.742347
>>>> Average number of links: 1.535714
>>>> 21 regions with no links:
>>>> 3 6 11 13 14 15 16 24 25 27 28 35 36 38 41 47 48 51 52 53 54
>>>> Link number distribution:
>>>>
>>>> 0  1  2  3  4  5  8
>>>> 21 12 11  2  7  2  1
>>>> 12 least connected regions:
>>>> 1 5 7 17 19 20 21 30 33 34 45 55 with 1 link
>>>> 1 most connected region:
>>>> 37 with 8 links
>>>>
>>>> Weights style: W
>>>> Weights constants summary:
>>>>  n   nn S0       S1    S2
>>>> W 35 1225 35 39.26667 147.3
>>>>
>>>> I want to get a matrix [56 x 56] to work in excel with it.
>>>
>>> ?listw2mat should help, then write the matrix in a form that Excel can
>>> read. But note that your distance criterion leaves 21 of 56 observations
>>> with no neighbours.
>>>
>>> Hope this helps,
>>>
>>> Roger
>>>
>>>>
>>>> Thank you in advance.
>>>>
>>>> Rolando Valdez
>>>>
>>>> _______________________________________________
>>>> R-sig-Geo mailing list
>>>> R-sig-Geo at r-project.org
>>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>>>
>>>
>>> --
>>> Roger Bivand
>>> Department of Economics, Norwegian School of Economics,
>>> Helleveien 30, N-5045 Bergen, Norway.
>>> voice: +47 55 95 93 55; fax +47 55 95 91 00
>>> e-mail: Roger.Bivand at nhh.no
>>
>> Rolando Valdez
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>
> --
> Roger Bivand
> Department of Economics, Norwegian School of Economics,
> Helleveien 30, N-5045 Bergen, Norway.
> voice: +47 55 95 93 55; fax +47 55 95 91 00
> e-mail: Roger.Bivand at nhh.no
>
> ------------------------------
>
> Message: 4
> Date: Mon, 5 May 2014 22:40:54 +0000
> From: VIRGILIO GOMEZ RUBIO <Virgilio.Gomez at uclm.es>
> To: James Rooney <ROONEYJ4 at tcd.ie>
> Cc: "r-sig-geo at r-project.org" <r-sig-geo at r-project.org>
> Subject: Re: [R-sig-Geo] BYM model in R-INLA - how to specify priors
> 	individually
> Message-ID: <1399329652.3461.3.camel at Virgilio-Gomez>
> Content-Type: text/plain; charset="iso-8859-15"
>
> Dear James,
>
> You should be able to set the prior of your random effects using hyper=
> in the call to f(). In your particular case, you can try:
>
> #Create areas IDs to match the values in nc.adj
> nc.sids$ID<-1:100
> nc.sids$ID2<-1:100
>
> hyper.besag <-list(prec=list(prior="loggamma", params=c(.1, .1)))
> hyper.iid<-list(prec=list(prior="loggamma", params=c(.001, .001)))
>
> #Besag model with random spatial effect (i.e. BYM model)
> m2<-inla(SID74~NWPROP+
>    f(nc.sids$ID, model="besag", graph="nc.adj", hyper=hyper.besag)+
>    f(nc.sids$ID2, model="iid", hyper=hyper.iid),
>  family="poisson", E=nc.sids$EXP, data=as.data.frame(nc.sids),
>  control.predictor=list(compute=TRUE))
>
>
> Note that I have defined two different indices. You can probably use
> model="bym" to simplify the formula in your model. Also, run
> inla.models()$latent$bym to know the default definitions of priors of
> the hyperparameters.
>
> Hope this helps.
>
> Virgilio
>
>
>
> ------------------------------
>
> Message: 5
> Date: Tue, 6 May 2014 12:07:25 +0530
> From: Anusheema Chakraborty <anusheema at gmail.com>
> To: r-sig-geo at r-project.org
> Subject: [R-sig-Geo] Decision tree classification of satellite image
> 	in R
> Message-ID:
> 	<CAH89e5yuQ9k66Ga9FJTYOpGad8T6USEXmSLTA_vq0mdOOS9bzA at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> Hi!
>
> I am trying to classify satellite image in R using RWeka classifier,
> J48. I have a CSV file with the classes required, and raster data
> loaded in R. I am able to make the tree, however, I am not able to use
> the same tree to classify my satellite image.
>
> Here's how it goes.
>
> inputfile=read.csv("E://R/Trial/naini.CSV")
> m1 <- J48(Class~B1+B2+B3+B4+B5+B7, data = inputfile)
> if(require("party", quietly = TRUE)) plot(m1)
> raster<- brick("merge.tif")
> plotRGB(raster, 4, 3, 2, stretch="hist")
>
> And then I am attempting to use the tree generated to classify my
> satellite image, but I keep getting errors.
>
> predict (test_new, J48, filename=out_classify,
> progress='text',format='GTiff', datatype='FLT4S', type='response',
> overwrite=TRUE)
> Error in trim(filename) : error in evaluating the argument 'x' in
> selecting a method for function 'trim': Error: object 'out_classify'
> not found
>
> And if I change the arguments, this is what I get. I am not sure how
> to proceed from this point forward.
>
> predict (J48, test_new, filename=out_classify,
> progress='text',format='GTiff', datatype='FLT4S', type='response',
> overwrite=TRUE)
> Error in UseMethod("predict") : no applicable method for 'predict'
> applied to an object of class "c('R_Weka_classifier_interface',
> 'R_Weka_interface')"
>
> I am new to R, so I might take a while to decipher your answers. Any
> help would be greatly appreciated!
>
> Thanks!
>
>
> Best,
> Anusheema.
>
>
>
> --
> Regards
>
> Anusheema Chakraborty
> Ph.D. Scholar
> Department of Natural Resources, TERI University
> 10, Institutional Area, Vasant Kunj, New Delhi - 110070
> Website: www.teriuniversity.ac.in
>
>
>
> ------------------------------
>
> Message: 6
> Date: Tue, 6 May 2014 08:08:26 +0100
> From: James Rooney <ROONEYJ4 at tcd.ie>
> Cc: "r-sig-geo at r-project.org" <r-sig-geo at r-project.org>
> Subject: Re: [R-sig-Geo] BYM model in R-INLA - how to specify priors
> 	individually
> Message-ID:
> 	<75C8D19A1470D344A8AF5312F01160A602BC2BCC892E at GOMAIL.college.tcd.ie>
> Content-Type: text/plain; charset="us-ascii"
>
> Dear Virgilio,
>
> Many thanks - yes that is helpful!
> However in my own dataset I am finding those values lead to an oversmoothed
> model - i.e. the output is very uniform - practically flat across all areas.
> But I know from BUGS smoothing and also from cluster analysis that there
> should be areas of variation.
> What is if that controls the "degree of smoothing" for want of a better
> term!
>
> Many thanks,
> James
>
> ________________________________________
> From: VIRGILIO GOMEZ RUBIO [Virgilio.Gomez at uclm.es]
> Sent: 05 May 2014 23:40
> To: James Rooney
> Cc: r-sig-geo at r-project.org
> Subject: Re: [R-sig-Geo] BYM model in R-INLA - how to specify priors
> individually
>
> Dear James,
>
> You should be able to set the prior of your random effects using hyper=
> in the call to f(). In your particular case, you can try:
>
> #Create areas IDs to match the values in nc.adj
> nc.sids$ID<-1:100
> nc.sids$ID2<-1:100
>
> hyper.besag <-list(prec=list(prior="loggamma", params=c(.1, .1)))
> hyper.iid<-list(prec=list(prior="loggamma", params=c(.001, .001)))
>
> #Besag model with random spatial effect (i.e. BYM model)
> m2<-inla(SID74~NWPROP+
>    f(nc.sids$ID, model="besag", graph="nc.adj", hyper=hyper.besag)+
>    f(nc.sids$ID2, model="iid", hyper=hyper.iid),
>  family="poisson", E=nc.sids$EXP, data=as.data.frame(nc.sids),
>  control.predictor=list(compute=TRUE))
>
>
> Note that I have defined two different indices. You can probably use
> model="bym" to simplify the formula in your model. Also, run
> inla.models()$latent$bym to know the default definitions of priors of
> the hyperparameters.
>
> Hope this helps.
>
> Virgilio
>
>
>
> ------------------------------
>
> Message: 7
> Date: Tue, 6 May 2014 02:10:14 -0700 (PDT)
> From: az14 <abidi.zineb at gmail.com>
> To: r-sig-geo at r-project.org
> Subject: [R-sig-Geo] lAGRANGE MULTIPLIER Test and error in listw
> 	object
> Message-ID: <1399367414246-7586372.post at n2.nabble.com>
> Content-Type: text/plain; charset=us-ascii
>
> Dear List,
> I 'm trying to run  the Lagrange multiplier test (LM Test) using R.
> so i import my data file(don) and do an lm regression as bellow:
>
> don<-read.csv("donnees2.csv",header=TRUE,sep=";",dec=",")widad.lm<-lm(coop~dens_t1+perchom_t1+percvieux_t1+psdc_t1,data=don)
>> summary(widad.lm)
>
> Then i import my distance matrix( 1056*1056).
>
>
> matrice<-read.csv("matw2.csv",header=FALSEE,sep=";",dec=",")
>  mat<-do.call(rbind,matrice)
> dim(mat)
> is.matrix(mat)
> True
>  mat2<-mat%*%mat
>> dim(mat2)
> [1] 1056 1056
>> x <- mat2listw(mat2)
> When i run the LM test; with an nb2listw object, i get this error:
>
>  lm.LMtests(widad.lm,nb2listw(x$neighbours, glist=x$weights,
> style="W"),test=c("LMerr","RLMerr"))
> Erreur dans subset.listw(listw, subset, zero.policy = zero.policy) :
>   /Not yet able to subset general weights lists
> I tryed to do it with mat2listw, but i get error too.
>
> lm.LMtests(widad.lm, mat2listw(mat2),test=c("LMerr","RLMerr"))
> Erreur dans subset.listw(listw, subset, zero.policy = zero.policy) :
>   Not yet able to subset general weights lists
>
>
> Any help would be appreciated.
> Thank you.
> Zineb.
>
>
>
>
> --
> View this message in context:
> http://r-sig-geo.2731867.n2.nabble.com/lAGRANGE-MULTIPLIER-Test-and-error-in-listw-object-tp7586372.html
> Sent from the R-sig-geo mailing list archive at Nabble.com.
>
>
>
> ------------------------------
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>
> End of R-sig-Geo Digest, Vol 129, Issue 6
> *****************************************
>



More information about the R-sig-Geo mailing list