79337580

Date: 2025-01-07 23:09:42
Score: 1.5
Natty:
Report link

In your example, you are comparing a string ("2023-01-01") with the values stored in the "variable.name". Strings can not be compared but date objects can be. Probably you can do the following....

df$variable.name = as.Date(df$variable.name) #make sure the variable is date object

df2023 = subset(df,df$variable.name >= as.Date("2023-01-01") & df$variable.name <= as.Date("2023-12-31"))

Reasons:
  • No code block (0.5):
  • Low reputation (1):
Posted by: Chowdhury arafat hossain