Re: [R] problems with loop and plot function

From: Petr Pikal <petr.pikal_at_precheza.cz>
Date: Thu 13 Oct 2005 - 21:33:40 EST


Hi

you forgot to plot something before adding points (and actually you wanted lines).

plot(conc, log10(1-choixg), main ="fonction de choix", col= n, pch=20,
lwd = 3,
xlab = " concentration", ylab="proba de choisir la gauche", type="n")

for( n in c(1,3,5)) {
 x <- NULL; y <- NULL
 simResult <- simulation (5,n)
 conc <- simResult$conc
 choixg <- simResult$choixg
 print("n"); print(c(k=5, n)) ### what is this???  lines(conc, log10(1-choixg))
}

Isn't it time to read some introductory texts? :-)

HTH
Petr

On 13 Oct 2005 at 12:47, KOITA Lassana - STAC/ACE wrote:

To:             	R-help@stat.math.ethz.ch
From:           	"KOITA Lassana - STAC/ACE" <lassana.koita@aviation-civile.gouv.fr>
Date sent:      	Thu, 13 Oct 2005 12:47:27 +0200
Subject:        	[R] problems with loop and plot function

>
>
>
>
> Hi all R users,
>
> I have problems with my second loop for drawing the three curves in
> the same graphic. I need help please
>
> Thank you in advance
>
> ######################################################################
> ###
>
> simulation <- function(k, n){
>
> conc <- seq(0,100,by=0.5)
> #choixg <- seq(1, length(conc))
> choixg <- rep(0,length(conc))
> for (i in 1:length(conc)){
> choixg[i] <- (k + conc[i])^n/((k+conc[i])^n + (k+1)^n)
>
> }
> #return(data.frame(choixg, conc))
> return(list(choixg=choixg, conc = conc))
> }
> #cbind(simResult$conc, simResult$choixg,
> #format(Sys.time(),"%H:%M:%S"))
>
> for( n in c(1,3,5)) {
> x <- NULL; y <- NULL
> simResult <- simulation (5,n)
> conc <- simResult$conc
> choixg <- simResult$choixg
> prin("n"); print(c(k=5, n))
> points(conc, log10(1-choixg), main ="fonction de choix", col= n,
> pch=20,
> lwd = 3,
> xlab = " concentration", ylab="proba de choisir la gauche", type="l")
> }
>
>
> ######################################################################
> ###
>
>
> Lassana KOITA
> Etude Sécurité et Exploitation aéroportuaires / Aerodrome Safety &
> Statistical analysis Service Technique de l'Aviation Civile (STAC) /
> Civil Aviation Technical Department Direction Générale de l'Aviation
> Civile (DGAC) / French Civil Aviation Tel: 01 49 56 80 60 Fax: 01 49
> 56 82 14 E-mail: Lassana.Koita@aviation-civile.gouv.fr
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html

Petr Pikal
petr.pikal@precheza.cz



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Oct 13 21:43:58 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 18:50:13 EST