I have the following sqldf:
library(sqldf)
B <- sqldf(
" select *
, CASE
WHEN Length = '1 day' THEN 1
WHEN Length = '2 days' THEN 2
WHEN Length = '4- 8 weeks' THEN 42
WHEN Length = '26+ weeks' THEN 180
END as lengthI
from A
"
)
summary(B)
I was expecting to get lengthI as numeric, but somehow I got it as character ("2", "1", )
My questions are: 1. Why sqldf did not generate numeric var as expected? 2. Is there a way I can force type of lengthI with sqldf?
Thanks a lot.