내용

글번호 712
작성자 heojk
작성일 2017-07-10 08:55:40
제목 Save R plot as a BLOB
내용 ## 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)