Alejandro Lee
Alejandro Lee

Reputation: 167

R - Function Error with IF Statement

I am getting the following error for the code: Error: unexpected '}' in "}"

csv_etl <- function(client) {
  if (client = 'OXF') {
    print('I am OXF')
  }
}

Is my syntax incorrect? I've counted the curly braces and parenthesis and they all are closed.

Upvotes: 0

Views: 37

Answers (1)

thc
thc

Reputation: 9705

Use a double equal sign:

csv_etl <- function(client) {
  if (client == 'OXF') {
    print('I am OXF')
  }
}

Upvotes: 2

Related Questions