Re: [R-sig-eco] doubt in generating loops with For

2015-04-17 Thread Rodrigues
Hello Thiago,


You keep doing the same mistake. When you pass z as subset to comm z will be
the z th column and you only has 10 columns so you will always receive the
out of bound. If I understood correctly you are trying to repeat a process
1000 times if yes follow a code above. I'm not sure that the nested loop is
the right thing but it works.

I don't know the diversity index that you are computing so I'm sorry if it's
not the result that you are looking for. But anyways the code now works so I
believe that you can fix it if i did wrong.

regards


library(vegan)


comm-t(data.frame(sp1=rpois(10, 1), sp2=rpois(10,1), sp3=rpois(10,1),
   sp4=rpois(10,1), sp5=rpois(10,1)))

traits-t(data.frame(sp1=rnorm(5,1.2,.2),sp2=rnorm(5,2,.5),
 sp3=rnorm(5,3,.3), sp4=rnorm(5,0.5,.2),
 sp5=rnorm(5,.9,.6)))

dist-vegdist(traits,gower)
comm-as.matrix(comm)

results-list()

for (i in 1:1000){
for (z in ncol(comm)){
comm1-apply(comm,2,sample)
 results[i]-(((t(comm1[, z]) %*% (as.matrix(dist)^2) %*%
comm1[,z])/2/(sum(comm1[, z])^2))[1,1])
}
}




--
View this message in context: 
http://r-sig-ecology.471788.n2.nabble.com/doubt-in-generating-loops-with-For-tp7579393p7579401.html
Sent from the r-sig-ecology mailing list archive at Nabble.com.

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


[R-sig-eco] Help with a function

2014-06-06 Thread Rodrigues
Dear R users,


I’m trying to build a function to select random samples idf’s from a
database.
So, my data frame had 2 columns and 575 rows. Follow bellow an example of my
database
Idf1casod
12  1
14  1
15  1
16  1
17  3
18  3
19  3
21  3
25  1
24  1
26  1
28  1
29  3
32  3
33  3
35  1
36  3
37  1
48  3

So my function is

blinding=function(sample){
  sort=sample(idf1,10,replace=F) 
  return(sort2)
}

It is pretty simple and I would like to add one more step in my choice. I
would like to link my choice to casod stats. Thus if casod==3 sample would
be random idfs could not be an idf with casod=1. Does someone can help me?




--
View this message in context: 
http://r-sig-ecology.471788.n2.nabble.com/Help-with-a-function-tp7578931.html
Sent from the r-sig-ecology mailing list archive at Nabble.com.

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


Re: [R-sig-eco] Help with a function

2014-06-06 Thread Rodrigues
Hello,

I would like to thanks everyone for the help.
I did this one:

blinding=function(sampling){
  sort1=sample(idf[casod==1],30,replace=F)
  sort2=sample(idf[casod==3],30,replace=F)
  var1=factor(c(rep(1,30),rep(2,30)),labels=c(Positivo,Negativo))
  var2=cbind(c(pos=sort1,neg=sort2))
  var3=sample(1:60,replace=F)
  df=data.frame(Status=var1,IDF=var2,TRP=var3) 
  return(write.csv(df,file=Piloto.csv,row.names=F))

It`s not exactly a function but works for me. 
BTW I found this site:
http://manuals.bioinformatics.ucr.edu/home/programming-in-r
I`ll try to learn a little more about r functions


Regards,
Moreno




--
View this message in context: 
http://r-sig-ecology.471788.n2.nabble.com/Help-with-a-function-tp7578931p7578939.html
Sent from the r-sig-ecology mailing list archive at Nabble.com.

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


Re: [R-sig-eco] R-sig-ecology (72-19): Plot question

2014-03-24 Thread Rodrigues
Dear Michal,

In this case they have only two variables: (i) time spend in each prey and
(ii) prey type. Would be better if he use bar graphs. So if are necessary
show the time spend for each spider I suggest the follow commands:



spider2=as.factor(spider)
plot(time~prey)
library(gplots)
mt=tapply(time,prey,mean)
ept=tapply(time,prey,sd)/sqrt(tapply(time,prey,length))
barplot2(mt,plot.ci=T,ci.u=mt+ept,ci.l=mt-ept,ylim=c(0,200),ylab=Mean of
time spending in each prey)

barplot(tapply(time,list(prey,spider),mean),beside=T,ylim=c(0,250),col=c(Gray,Gray10,Gray20,Gray30,Gray40,Gray50),xlab=Spider,ylab=Time
spend in each prey)
levels(prey)
labs=c(Ant,CocKroach,Fly,Isopod,Termite)
legend(topleft,labs,fill=c(Gray,Gray10,Gray20,Gray30,Gray40,Gray50),bty=n)

If u dont like bar use stripchart function for bars :)




--
View this message in context: 
http://r-sig-ecology.471788.n2.nabble.com/Re-R-sig-ecology-72-19-Plot-question-tp7578769p7578775.html
Sent from the r-sig-ecology mailing list archive at Nabble.com.

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


Re: [R-sig-eco] R-sig-ecology (72-19): Plot question

2014-03-24 Thread Rodrigues
Ok my bad. Stripchart doenst plot bar...
Just like this

time=(c(rnorm(10,2),rnorm(10,3),rnorm(10,1.5),rnorm(10,.5),rnorm(10,1)))
prey=factor(c(rep(1,10),rep(2,10),rep(3,10),rep(4,10),rep(5,10)),labels=c(Ants,Cockroach,Fly,Isopod,Mite))
stripchart(time~prey,vertical=T,pch=1,method=jitter,ylab=Time spend in
each prey type,cex.axis=1.4,cex.lab=1.4,cex=1.2)

Regadrs,
Moreno



--
View this message in context: 
http://r-sig-ecology.471788.n2.nabble.com/Re-R-sig-ecology-72-19-Plot-question-tp7578769p7578778.html
Sent from the r-sig-ecology mailing list archive at Nabble.com.

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


[R-sig-eco] richness estimators

2011-03-25 Thread Fernando Rodrigues da Silva
Hello everyone,

I get two questions about richness estimators ..

When I use the command below poolaccum from library (vegan) I have the 
following 
result

estimator - poolaccum (est, permutations = 100, minsize = 1)
summary (estimator, display = jack1)

N Jackknife 1   2.5%  97.5%   Std.Dev
1 5.21 2.000 8.525000 1.79952294
2 9.60 4.2125000 14.50 2.65622958
3 12.116667 6.667 17.508333 2.83689616
4 13.607500 8.500 18.25 2.86595635
5 14.10 9.600 18.60 2.62628516
 6 14.751667 9.833 18.17 2.34706099
7 15.408571 10.7142857 18.285714 2.11297296
8 15.54 11.750 19.25 2.10607886
9 15.77 12.311 18.44 1.80268052
10 15.974000 12.900 18.50 1.40105444
11 16.198182 13.3409091 19.022727 1.36031920
12 16.089167 14.833 17.67 0.93069726
13 16.012308 14.8461538 17.692308 0.72956962
14 15.857143 15.8571429 15.857143 0.

1) I would like to know which command I have to use to get the mean and
standard deviation ... What command I use to use these data as vectors
separately ..

2) For the ACE and ICE estimators they consider the abundance of 10 individuals
or incidence in 10 samples as being rare, I wonder if anyone
know how to change this value.

Thank you for your attention.

Best regards,

 
FERNANDO RODRIGUES DA SILVA
===

Doutor em Biologia Animal 

Lab. de Ecologia Animal, UNESP - São José do Rio Preto - Cep 15054-000

Celular:(17) 8126-4085  (17) 9774-3163

MSN:  bigos...@hotmail.com   Skype: presidentedalaponia

Lattes:http://buscatextual.cnpq.br/buscatextual/visualizacv.jsp?id=K4777878T8



  
[[alternative HTML version deleted]]

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology