cis-ds / Discussion

Public discussion
10 stars 15 forks source link

hw02: trying to use filter function in question 5, getting error message #170

Closed avivawaldman closed 2 years ago

avivawaldman commented 3 years ago

I am trying to use the filter function with the logical operator like this "comparison1<-filter(mass_shootings, race=="White"|"Black")" in order to set up my data for a plot in question 5, but am getting the error message "Problem with filter() input ..1. x operations are possible only for numeric, logical or complex types i Input ..1 is race == "White" | "Black"." This is how it looks in the textbook and when I google the filter function so I am rather confused?

fdicera commented 3 years ago

With the filter() function, you need to specify the variable you are subsetting in both cases, so: race == "White" | race == "Black". Chapter 5.2.2 has additional explanations and a relevant example, if needed. You can also use the shorthand %in% to avoid having to type out race == each time (more details on how to use this are also in the link, if interested).

In the future, please go ahead and post homework related questions on the issues page for that assignment, just so it's easier for everyone to see what's been posted for that homework!