I have a column ML_Latest which contains values as following :
ML_Latest
1st row)95 250 95
2nd row)95 500
3rd row)250 500
I want to make a new column which contains the addition of these numbers for example:
440
595
750
How can I do it in R?
I have a column ML_Latest which contains values as following :
ML_Latest
1st row)95 250 95
2nd row)95 500
3rd row)250 500
I want to make a new column which contains the addition of these numbers for example:
440
595
750
How can I do it in R?
Using rowSums:
Your dataset:
df=read.table(text="95 250 95
          95 500 NA
          250 500 NA",header=FALSE)
df$sum=rowSums(df,na.rm = TRUE)
Output:
   V1  V2 V3 sum
1  95 250 95 440
2  95 500 NA 595
3 250 500 NA 750
