[R] loop for plot function

KOITA Lassana - STAC/ACE lassana.koita at aviation-civile.gouv.fr
Wed Oct 12 17:00:31 CEST 2005





Hello all R users,
I would like to add another loop to my following R code ( it works for the
moment correctly) , which will be able to me to vary n (see the code) from
1 to 4 or 5.
And I also would like apply the plot function in this case, eg all four or
five figures in the same graphic (n= 1, 2, ..., 4 ou 5)
I have tested one, but unsuccessfully.
I need you to solve this problems

Thank you


###########################################################################"

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))

}

#choixg <- simulation(5,2)
#mydf<-simulation(5,1)
simResult <- simulation (5,5)
#plot(mydf$conc, log10(1-mydf$choixg), main ="fonction de choix", col=
#"blue", pch=20,
#xlab = " concentration", ylab="proba de choisir la gauche")

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

lines(simResult$conc, log10(1-simResult$choixg), col= "red", lwd = 3)

#cbind(simResult$conc, simResult$choixg, format(Sys.time(),"%H:%M:%S"))

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 at aviation-civile.gouv.fr




More information about the R-help mailing list