I am needing to see how to update one column in a data frame where the employeeID matches that of another data frame.
For example:
df1 >
empID salary
1 10000
2 15000
3 0
df2 >
empID salary2
1 10000
2 15000
3 20000
I am needing to see how to update it where df1$salary = 0, then update it where df1$empID = df2$empID.
I tried this but received "No such column: salary2" error :
df1$salary <- ifelse(df1$salary == 0,sqldf("UPDATE df1 SET salary = salary2 WHERE df1.empID = df2.empID"),df1$salary)
sqldf(c("update ...", "select * from df1"))to actually return something or else instead of usingupdateuse the appropriate SQLselectstatement.