I have the following dataframes. I would like to match values in column X across the two data frames (values of X across the two columns are the same) and add the values in Cost column and create a new dataframe that contains column X, column lat, column long and then shows consolidated/summed up values as shown below
data1
        X    Cost    lat       long        
    1 RA123  60     -113.8       NA
    2 RA124  50     -113.8       NA
    3 RB131  40     -113.8       NA
    4 RB132  30     -113.8       NA
    5 RB133  20     -113.8       NA
    6 RC134  10     -113.8       NA
    7 RC135  No     -113.9       NA
    8 RD136         -113.7       NA
data2
   X     Cost    lat       long        
1 RA123  10    -113.8      NA
2 RA124  20    -113.8       NA
3 RB131  40    -113.8      NA
4 RB132  30    -113.8       NA
5 RB133  50    -113.8       NA
6 RC134  60    -113.8       NA
7 RC135  No     -113.9       NA
8 RD136         -113.7       NA
consolidated # this dataframe contains sum of cost from dataframe 1 and 2 but also has original columns
       X     Cost    lat       long        
    1 RA123  70     -113.8       NA
    2 RA124  70     -113.8       NA
    3 RB131  80     -113.8       NA
    4 RB132  60     -113.8       NA
    5 RB133  70     -113.8       NA
    6 RC134  70     -113.8       NA
    7 RC135  No     -113.9       NA
    8 RD136         -113.7       NA
Some values in "Cost" are text strings and some are blank/no values. I'd like to ignore text strings for now and where there is no value/empty cell, I'd like an NA.
Update: I used the following code to get the summed up values for Cost and retain all original columns and overlook text/string and NA values i.e. wherever there is a text string, the value shows NA. The empty cells where there was no value entered also shows NA:
Consolidated$Cost<- as.numeric(as.character(Consolidated$cost.x)) + as.numeric(as.character(Consolidated$cost.y))
Now, what I need to do be able to do is wherever there were text strings, I need to be able to display "TextValue" as the value as opposed to NA. Just to highlight, whatever the string value might be, it will be the same for any given value of X across data1 and data2 both.
Update: I've had to rename those rows in consolidated column as "TextValue" using:
Consolidated$Cost[is.na(Consolidated$Cost)] <- "TextValue" 
I was hoping to do so within the first step itself. But I guess this works too.
 
     
    