2

I have a CSV file that I want to analyze in R. One of the variable names is Team/NOC. When I try to filter this variable I get an error message (probably because of the forward slash in the variable name).

  • My code:
filter(Medals,Team/NOC=="Japan")
  • The error message:

Error: Problem with filter() input ..1. i Input ..1 is Team/NOC == "Japan". x object 'Team' not found

So, how can I solve this problem please?

lovalery
  • 4,254
  • 3
  • 13
  • 27

1 Answers1

2

As stated in this answer:

A pair of backticks is a way to refer to names or combinations of symbols that are otherwise reserved or illegal.

You need to protect your attributes doing the following:

filter(Medals, `Team/NOC` == "Japan")
Francisco Maria Calisto
  • 2,317
  • 4
  • 20
  • 44