I have a data set of surveys and I am trying to calculate row by row. The new output column should be based on data from that row. I can make the new row and do that math, but the result is applied to all rows.

How do I get the math output column to match the math on a row by row basis? My code is below, and it works for calculating the surveys in the new column correctly. The trouble is, it calculates for all rows instead of just row 2.

```
tvd <- function(depth, inclination) {
tvd <- cos(inclination * pi / 180) * depth
print(tvd)
}
surveys_1 <- surveys
surveys_1$TVD <- tvd(surveys_1[2,1], surveys_1[2,2])
head(surveys_1)
```

Does anyone know how to fix this?