Filter function - ERROR - HELP

Hi
I tried to filter my data "Data_m2" by my "ESG_Score_Sustainalytics" variable grouping them by years using my "Data_Date_Security_Monthly" . However, it gives me this error. I want my dataset to be organised monthly but at the same time split them by years.

filter(Data_m2, ESG_Score_Sustainalytics, group_by(Year))
Error: Problem with filter() input ..1.
:information_source: Input ..1 is ESG_Score_Sustainalytics.
x Input ..1 must be a logical vector, not a double.

Can someone help me with this error? Where am I wrong?
Thanks

Seems like ESG_Score_Sustainalytics is a numerical variable. So, to filter on this variable, there has to be a logical operation. Something like

filter(Data_m2, ESG_Score_Sustainalytics == 1)
filter(Data_m2, ESG_Score_Sustainalytics < 10)

etc.

Also, the group_by(Year) should be written as another function call after the filter, not an additional argument to filter.

filter(Data_m2, ESG_Score_Sustainalytics == 1) %>% group_by(Year)

One problem is that ESG_Score is a set of numeric values. You need to filter the data with some logical condition like

ESG_Score >= 10

I am not sure what you mean to do with group_by(Year). That is not used inside of a filter() function. Do you intend to sort the resulting data?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.