내용 |
## open connection
library(RODBC)
channel <- odbcConnect("")
## create a plot
x <- rnorm(100,0,1)
## save plot as temp file
png(filename="temp.png", width=500, height=500)
hist(x, col="light blue")
dev.off()
## read temp file as a binary string
plot_binary <- paste(readBin("temp.png", what="raw", n=1e6), collapse="")
## insert binary sting into a table
sqlQuery(channel, paste("INSERT INTO test VALUES (1, x'",plot_binary,"')", sep=""))
## close connection
odbcClose(channel) |