I am wondering if there is an effective function or package in R that returns the time zone of the state that is fed into it. For example, if you fed the function "CA", it would return with "PST" or "Pacific".
>function("CA")
>"PST"
Thanks
I am wondering if there is an effective function or package in R that returns the time zone of the state that is fed into it. For example, if you fed the function "CA", it would return with "PST" or "Pacific".
>function("CA")
>"PST"
Thanks
You could use some code like this, if you have a list of what results you want for each state (taking account of MrFlick's commment).
library(dplyr)
case_when(
x %in% c("1", "2", "3") ~ "Central Time",
x %in% c("4", "5", "6") ~ "Pacific Time",
)
Here, 1,2,3 would be the names of states and you can add time zones as necessary.