Hello I´am trying to subtract the column B
from column A
in a dat
matrix to create a C
column (A
- B
):
My input:
A B
1 2
2 2
3 2
4 2
My expected output:
A B C
1 2 -1
2 2 0
3 2 1
4 2 2
I have tried: dat$C <- (dat$A - dat$B)
, but I get a: ## $ operator is invalid for atomic vectors
error
Cheers.