How to print R variables in middle of String
You're missing some extra quotes. Try this:
cat('<set name=\"',df$timeStamp,'\" value=\"',df$Price,'\" ></set>\n')
Here's a working example of what I mean:
cat("a b c -> \"", letters[1:3], "\"\n")
The problem is that R does not evaluate any expression withing the quotes - it is just printing the string you defined. There are multiple ways around it. For example, you can use the sprintf
function (untested because you do not provide a reproducible example):
cat(sprintf("<set name=\"%s\" value=\"%f\" ></set>\n", df$timeStamp, df$Price))