Error in switch(Z, "onlineloc == instore", "onlineloc != instore") : EXPR must be a length 1 vector

deltime=readline(prompt="Please enter deliery date and time\t") # for input of date and time
#> Please enter deliery date and time   
T=as.POSIXlt.character(deltime)                                          # to pass the time in formate R accepts
#> Error in as.POSIXlt.character(deltime): character string is not in a standard unambiguous format

if(Sys.time()+60*30 < T){

f = function(){
  a = runif(1500,1,10)
  return( a=as.integer(a))
onlineloc = data.frame(x = f(), y = f())
instore = data.frame(a = f(), b = f())
Z=if(onlineloc == instore)
{print(onlineloc[Z[,1] & Z[,2], ])

print("Package Delivered no of orders left\n")
}else {
  switch(Z,"onlineloc == instore","onlineloc != instore")
}else if(Sys.time()+60*30==T){
} else {print("Enter Valid Time")}
#> [1] "Enter Valid Time"

i want to use switch statement as the time input is greater than system time but its giving error
Created on 2019-09-16 by the reprex package (v0.3.0)

Hi @Emmadadil. Can you explain more about the purpose of switch that you want in your case.

i want to keep the if loop runing till the time T is greater than system time whether online==instore or online!=instore it should switch to start again as T > sys.time please guide

Hi @Emmadadil. I still cannot get what you mean about using switch. And the meaning of the variable Z is also unknown. Can you clarify more about this.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.