I have a data frame. I need to search for column "a", and if "a" equals "foo", column "b" equals "found"

```
a <- c("foo", "bar", "baz", "foo")
b <- c(0, 0, 0, 0)
df <- data.frame(a, b)

f <- function (x){
  if (x["a"] == "foo"){
    x["b"] <- "confirm"
  }
}

result <- apply(df, 1, f)

```

The intended result is

```
a        b
"foo"    "confirm"
"bar"    0
"baz"    0
"foo"    "confirm"

```

but when I do this, result returns: 

```
 [[1]]
[1] "confirm"

[[2]]
NULL

[[3]]
NULL

[[4]]
[1] "confirm"

```

and View(result) gives the error:
 Error in View : arguments imply differing number of rows: 1, 0

Is it adding another dimension to the data frame?