[R-sig-eco] automating ações

Kátia Emidio kat.emidio at gmail.com
Tue Sep 15 20:56:01 CEST 2015


Dear Erickson
 Here is the code:


require(spatstat)
require(foreign)
require(rgeos)
require(maptools)


options(digits=4)
dados.pol<-readShapePoly("area_de_estudo.shp")#lendo o contorno da  área
de estudo
plot(dados.pol)

dados.riq<-read.table("test_richness.txt", head=T, sep="\t")
sp<-dados.riq$Cod_NC
sp<-as.factor(sp)

pt_X<-dados.riq$X_UTM
pt_X<-as.numeric(pt_X)
pt_Y<-dados.riq$Y_UTM
pt_Y<-as.numeric(pt_Y)
pts_M<-sp
W<-as(dados.pol,"owin")


ppp_zona<-ppp(pt_X,pt_Y,window=W, marks= pts_M)
unitname(ppp_zona)<-"meters"
rique<-as.numeric(dados.riq$riqueza)
length(rique)

dap<-dados.riq$DAP
ppp_zona$marks=data.frame(sp=ppp_zona$marks, riqueza=rique,dap=dap)
ppp_zona
ppp.zona.dap<-ppp_zona

ppp_zona.sp<-split(ppp_zona, f="sp")
ppp_zona.sp
ppp_zona.sp


ppp_zona.sp<-lapply(ppp_zona.sp, function(x){x=x; x$marks=x$marks$riqueza;
return(x)})
ppp_zona.sp


bw.smoothppp(ppp_zona.sp[["Rino_macr"]],hmin=NULL, hmax=NULL, warn=TRUE)


plot(Smooth(ppp_zona.sp[["Rino_macr"]],sigma=19.26))


dev.print(jpeg,file="Rino_macr.jpg", bg="transparent", quality=300, width =
1024, height = 768)

Cheers,

2015-09-15 14:01 GMT-04:00 Kátia Emidio <kat.emidio at gmail.com>:

> Dear all,
>
> I´m a beginner in using FOR in order to create a loop in R to automate
> ações in it.
>
> I have a script, attached, and I need to perform it for all species in the
> file  (test_richness). The package I'm using is the SpatStat. The loop
> needs to be created before the "bw.smoothppp" function (line 45), which get
> the sigma value, that is used as a parameter for the  "plot(Smooth...)..
> and the image needs to be automatic generated as a file.
> I'll appreciate any help!
> Cheers,
>
> --
> Kátia Emídio da Silva DSc
> Eng. Florestal
> Manaus/AM
>
>
>
> Forestry Engineer
> Manaus/AM-Brazil
>



-- 
Kátia Emídio da Silva DSc
Eng. Florestal
Manaus/AM



Forestry Engineer
Manaus/AM-Brazil

	[[alternative HTML version deleted]]



More information about the R-sig-ecology mailing list