R functions not working correctly on Linux (working well on windows)

I am trying to do the following:

subset_Portugal <- subset(data_frame, data_frame$iso_code == "PRT" & data_frame$date <= "2021-02-27" & data_frame$date >= "2020-04-01")

Works great on windows, but on Linux (a fresh install) I get the following error:

> subset_Portugal <- subset(data_frame, data_frame$iso_code == "PRT" & data_frame$date <= "2021-02-27" & data_frame$date >= "2020-04-01")
Warning messages:
1: In Ops.factor(data_frame$date, "2021-02-27") :
  ‘<=’ not meaningful for factors
2: In Ops.factor(data_frame$date, "2020-04-01") :
  ‘>=’ not meaningful for factors

Why is this happening on Linux? How may I fix it?

Welcome to the community!

Since you mentioned that it's a fresh install on Linux, I'm thinking it may not be the latest version of R. Linux usually lags quite a bit in the default repo. Can you confirm that you have same version in both Windows and Linux?

I'm thinking that probably you have 4+ in Windows and <4 in Linux. That'd explain the string to factor change, as before version 4, strings were converted to factor by default on R.

But if you find that you have version in both OS, please share share a reproducible example and your session info.