I have a problem with selecting a variable that should contain a certain range of values. I want to split up my variable into 3 categories. Namely; small
, medium
and big
. A piece of context. I have a variable named obj_hid_woonopp
which is (size in m2) and it goes from 16-375. And my dataset is called datalogitvar
.
I'm sorry I have no reproduceable code. But since I think it's a rather simple question I hope it can be answered nonetheless. The code that I'm using is as follows
datalogitvar$size_small<- as.numeric(obj_hid_WOONOPP>="15" & obj_hid_WOONOPP<="75" )
datalogitvar$size_medium<- as.numeric(obj_hid_WOONOPP>="76" & obj_hid_WOONOPP<="100" )
datalogitvar$size_large<- as.numeric(obj_hid_WOONOPP>="101")
When I run this, I do get a result. Just not the result I'm hoping for. For example the small category also contains very high numbers. It seems that (since i define "75"
) it also takes values of "175"
since it contains "75"
. I've been thinking about it and I feel it reads my data as text and not as numbers. However I do say as.numeric
so I'm a bit confused. Can someone explain to me how I make sure I create these 3 variables with the proper range? I feel I'm close but the result is useless so far.
Thank you so much for helping.