Hi,

Welcome to the RStudio community!

The `ifelse`

function does not wrap the whole statement, but just the columns you like to work on like this

```
adj[,c(1)] = ifelse(adj[,c(1)]==1, sum(adj[,c(1)]-adj[c(1),]),0)
```

All it does is take a vector of T/F, then returns values from two other vectors depending on the case. It's also possible to just return one value for either T or F, as you are doing here (the sum or 0).

Example:

```
# Vector input, one possible true of false answer
ifelse((1:5 %% 2) == 0, "even", "odd")
#> [1] "odd" "even" "odd" "even" "odd"
# Vector input, pick corresponding index value from true or false vectors
ifelse((1:5 %% 2) == 0, letters[1:5], LETTERS[1:5])
#> [1] "A" "b" "C" "d" "E"
```

^{Created on 2022-04-18 by the reprex package (v2.0.1)}

My answer if just helping you fix your current error, but I'm not 100% sure if your code captures the function one you provided, so please check this.

Hope this helps,

PJ