How can I save values to .txt file with RDataFrame?

You can also follow the example of the link above.

namely using the function Take() or Foreach().

Or you can use Snapshot() to save a TTree, and then export it as CSV