Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to save R plot image to database?

Tags:

database

r

rodbc

I'd like to save a plot image directly to the database.

Is the best way in R to do this:

  1. Write the plot image (png) to the filesystem
  2. Read the file that was written
  3. Send the file to the database via query (RODBC)

Ideally I'd like to combine steps 1 and 2 above by simply write the png image to a binary connection. Does R support this?

like image 311
Bob Albright Avatar asked Sep 14 '25 04:09

Bob Albright


1 Answers

No, the graphics devices are file-based, so your steps 1-3 are correct. You need a fourth to unlink the temporary file but that is about it.

like image 152
Dirk Eddelbuettel Avatar answered Sep 15 '25 20:09

Dirk Eddelbuettel