Search code examples
rsink

Appending Multiple Dataframes Using Sink


I am trying to put three dataframes (that are filled from a database) in one csv file, so I used sink().

sink('file.csv')
cat('Dataframe 1')
write.csv(df1)
cat('--------------')
cat('\n')
cat('\n')
cat('Dataframe 2')
write.csv(df2)
cat('--------------')
cat('\n')
cat('\n')
cat('Dataframe 3')
write.csv(df3)
cat('----------------')
(sink)

This results with code being displayed at the bottom enter image description here

How can I remove this?


Solution

  • At the end, you have

    (sink)
    

    This is a reference to the sink function, and will print the source code of that function. It seems that what you want is to stop diverting output to the sink. Try this instead:

    sink()