[R] need help to manipulate function and time interval

Uwe Ligges ligges at statistik.uni-dortmund.de
Fri Aug 10 22:38:46 CEST 2007



KOITA Lassana - STAC/ACE wrote:
> Hi R-users,
> 
> I have to define a noise level function L and its energy in the various 
> moment of the day by:
> 
>  if time is between 18:00:00 and 23:59:59 then  L[j] <- L[j]+5 and W <- 
> 10^((L+5)/10) 


What kind of object is time? Just a character or some Time/Date format?
Do you know the day?

If time is between 18:00:00 and 23:59:59, should the next point (time is 
between 22:00:00 and 05:59:59) be executed additionally if time is, 
e.g., 23:00:00 or is there any other condition I cannot see?

All the information is quite essential in order to help...

BTW: I don't think the rest of your code is sensible (at least, some 
braces are missing).

Uwe Ligges



> if time is between 22:00:00 and 05:59:59 ==> L <- L+10  and W <- 
> 10^((L+10)/10)
> else
> L=L and W = W
> 
> Could someone help me to realize this function please? You will find my 
> following proposal  code, but my main problem is to handle the time 
> interval.
> 
> Best regard
> 
> ###########################
> myfunc <- function(mytab, Time, Level)
> {
> vect <- rep(0, length(mytab))
> for(i in 1:length(vect))
>    {
>       for(j in 1:length(Time))
> 
>             if(time[j] is between 18:00:00 and 23:59:59) 
> 
>             L[i] <- L[j]+5 
>  
>            vect[i] <- 10^((L[i])/10
> 
>             if (time[j] is between 22:00:00 and 05:59:59)
> 
>             L[i] <- L[j]+10 
>  
>              vect[i] <- 10^((L[i])/10
> 
>             else 
>  
>            L[i] = L[j]
>  
>           vect[i] <- 10^((L[i])/10
>      } 
> } 
> 
> #######################
> 
> Lassana KOITA 
> Chargé d'Etudes de Sécurité Aéroportuaire et d'Analyse Statistique  / 
> Project Engineer Airport Safety Studies & 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 
> Headquarters
> Tel: 01 49 56 80 60
> Fax: 01 49 56 82 14
> E-mail: Lassana.Koita at aviation-civile.gouv.fr
> http://www.stac.aviation-civile.gouv.fr/
> 	[[alternative HTML version deleted]]
> 
> 
> 
> ------------------------------------------------------------------------
> 
> ______________________________________________
> R-help at 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
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list