Hi, I don’t really have a problem, but I’m trying to improve my R abilities and 
I think I might use some help.


I’ve done this graph:


a<-.05; b<- 1; kr1<-70;kr2<-60;kr3<-50
K1<- kr1/a; K2<- kr2/a; K3<- kr3/a
curve(kr1*x*(b-a*x/kr1),col="blue",from=-50,to=1500,xlab="Nombre 
d'individus",ylab="Creixement"); 
curve(kr2*x*(b-a*x/kr2),col="green",add=T);
curve(kr3*x*(b-a*x/kr3),col="red",add=T);
title("Relació del creixement en funció del nombre d'individus")
abline(h=0,v=0,lty=3)
legend("topright",legend =c("Kr1=70", "Kr2=60", "Kr3=50"),pch = 22, col=NA, 
pt.bg=c("blue","green","red"))
points(K1,0, col="blue",pch=20); text(K1,-1000,"K1=1400",col="blue")
points(K2,0, col="green",pch=20); text(K2,-1000,"K2=1200",col="green")
points(K3,0, col="red",pch=20); text(K3,-1000,"K3=1000",col="red")


And it has everything I need it to, but I’m sure I could have obtained the same 
image using a color vector, a kr vector and a K vector that gathers all my 
values for those variables. I know nothing about loops and I think they’re 
what’s needed here. 


Could you help me optimize this?


Thank you very much.
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to