1

I have this dataset with two columns and four rows

x <- c(-1, -2, 2, 3)
y <- c(0, -3, 2, -2)

cbind(x, y)

I want to sum the absolute values of columns x and y using dplyr and add results in column z. It should look like this

z <- c(1, 5, 4, 5)

cbind(x, y, z)

I have tried using mutate and place the argument abs in different positions of a command but nothing works.

Can anyone help this R beginner solve this apparent simple problem?

Thanks,

user7476990
  • 11
  • 1
  • 7

0 Answers0