Hey guys, i need write wt function with using this code, help me please
Pas_arrival=runif(1, min = 0, max=100)
Bus_arrival=seq(10, 100, by = 10)
t <- Bus_arrival-Pas_arrival
t=min(t[t>=0])
Hey guys, i need write wt function with using this code, help me please
Pas_arrival=runif(1, min = 0, max=100)
Bus_arrival=seq(10, 100, by = 10)
t <- Bus_arrival-Pas_arrival
t=min(t[t>=0])
Highlight the code in an RStudio source pane. From the top menu bar, choose Code | Extract Function, provide a name when prompted and you will get
wt <- function() {
Pas_arrival=runif(1, min = 0, max=100)
Bus_arrival=seq(10, 100, by = 10)
t <- Bus_arrival-Pas_arrival
t=min(t[t>=0])
}
However, `wt()` will appear to do nothing because no value was returned. Either add `return(t) after the last line or just remove `t=`
This might not give you what you want if you have `Pas_arrival` and `Bus_arrival` vectors that are not random. How would you modify the function to take arguments representing those values?
This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.