Hello,
I am trying to perform addition and subtraction on same column
So I got the column with name total and it has values
1
2
3
4
5
I need to get a<- 1+2+3 = 6
B<- 4+5 =9
C = b-a = 3
How can I write code for this ?
Please help me
Thank you
Hello,
I am trying to perform addition and subtraction on same column
So I got the column with name total and it has values
1
2
3
4
5
I need to get a<- 1+2+3 = 6
B<- 4+5 =9
C = b-a = 3
How can I write code for this ?
Please help me
Thank you
I would love to help you, but I don't understand what you are asking for help with it all.
Hi,
I agree with @nirgrahamuk. In order for us to help you with your question, please provide us a minimal reproducible example where you provide a minimal (dummy) dataset and code that can recreate the issue. Once we have that, we can go from there. For help on creating a Reprex, see this guide:
Good luck!
PJ
What the guys said above holds, but you can accomplish what you want with the following code.
data <- data.frame(Total = seq(1,5,1))
a <- sum(data[1:3,])
b <- sum(data[4:5,])
c <- b - a
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.