I have a large data set that I have imported from Excel to R. I want to get all the entries that have a negative value for a specific variable, MG. I use the code:
A <- subset(df, MG < 0)
However, A becomes empty, despite the fact that there are several entries with a value below 0. This is not the case when I am looking for values larger than 0, < 0. It should be added that there are N/A values in the data, but adding na.rm = TRUE does not help.
I also notice that R treats MG as a binary true/false variable since it sometimes contains 1 and 0.
Any idea what I have done wrong?
edit:
Country Region      Code Product name Year Value MG
Sweden  Stockholm   123  Apple        1991 244   NA
Sweden  Kirruna     123  Apple        1987 100   NA
Japan   Kyoto       543  Pie          1987 544   NA
Denmark Copenhagen  123  Apple        1998 787   0
Denmark Copenhagen  123  Apple        1987 100   1
Denmark Copenhagen  543  Pie          1991 320   0
Denmark Copenhagen  126  Candy        1999 200   1
Sweden  Gothenburg  126  Candy        2013 300   0
Sweden  Gothenburg  157  Tomato       1987 150   -55
Sweden  Stockholm   125  Juice        1987 250   150
Sweden  Kirruna     187  Banana       1998 310   250
Japan   Kyoto       198  Ham          1987 157   1000
Japan   Kyoto       125  Juice        1987 550   -1
Japan   Tokyo       125  Juice        1991 100   0
 
    