Skip to content

Commit

Permalink
Modified R scripts to work under windows
Browse files Browse the repository at this point in the history
  • Loading branch information
lsaravia committed Feb 27, 2014
1 parent be90238 commit 75fef0a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
16 changes: 12 additions & 4 deletions Fun_MFA.r
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,12 @@ calcDq_mfSBA <- function(fname,parms,recalc=FALSE)
syst.txt <- paste("./mfSBA ",fname, parms)
system(syst.txt)
}
pp <- read.table(sname, header=T)

pp <- read.delim(sname, header=T)

for(nc in 1:ncol(pp)){
if( class(pp[,nc ])=="factor") pp[,nc]<-as.numeric(as.character(pp[,nc]))
}

pp$Dq <- with(pp,ifelse(q==1,alfa,Tau/(q-1)))
pp$SD.Dq <- with(pp,ifelse(q==1,SD.alfa,abs(SD.Tau/(q-1))))
pp$R.Dq <- with(pp,ifelse(q==1,R.alfa,R.Tau))
Expand All @@ -83,7 +87,11 @@ calcDq_multiSBA <- function(fname,parms,recalc=FALSE)
syst.txt <- paste("./multiSpeciesSBA ",fname, parms)
system(syst.txt)
}
pp <- read.table(sname, header=T)
pp <- read.delim(sname, header=T)

for(nc in 1:ncol(pp)){
if( class(pp[,nc ])=="factor") pp[,nc]<-as.numeric(as.character(pp[,nc]))
}

pp$Dq <- with(pp,ifelse(q==1,alfa,Tau/(q-1)))
pp$SD.Dq <- with(pp,ifelse(q==1,SD.alfa,abs(SD.Tau/(q-1))))
Expand Down Expand Up @@ -168,7 +176,7 @@ plotDqFit <- function(fname,qname)
trellis.par.set(superpose.line=list(lty=3))

#show.settings()

if(names(zq1)[2]=="LogBox") names(zq1)[2]<-"Log.Box"
print(xyplot(logTr~Log.Box , data =zq1, groups=q, type=c("r","p"), scales=list(tck=-1),
#main=list(wtitle,cex=0.9),
auto.key=list(space = "right",title=expression(italic("q")),cex.title=.7, points=TRUE,cex=.7),
Expand Down
11 changes: 7 additions & 4 deletions testMFA.r
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
rm(list = ls())

setwd("~/Dropbox/cpp/SpatialAnalysis/mfsba")
# change this to the folder wich contains mfSBA
#
setwd("/cpp/mfsba")

source('Fun_MFA.r')

dq <- calcDq_mfSBA("rnd256.sed","q21.sed 2 512 20 S")
dq <- calcDq_mfSBA("rnd256.sed","q21.sed 2 512 20 S",F)

dq$Site <- "Random"

hist(dq$R.Dq)

dq1<- calcDq_mfSBA("b4-991008bio.sed","q21.sed 2 512 20 S")
dq1<- calcDq_mfSBA("b4-991008bio.sed","q21.sed 2 512 20 S",F)

hist(dq1$R.Dq)

Expand All @@ -26,7 +28,8 @@ gp <- ggplot(dq, aes(x=q, y=Dq, color=Site)) +
geom_point()
gp


# A publication quality graph requires lattice & Hmisc packages
#
plot_DqCI(dq)

plot_sed_image("t64-0100.sed","Neutral Multi species 2D distribution")
Expand Down

0 comments on commit 75fef0a

Please sign in to comment.