[R] Image into Excel file from R
Hans-Peter Suter
gchappi at gmail.com
Sun Apr 25 20:11:22 CEST 2010
> I am aware of the various packages (xlsReadWrite, RODBC) to get data
> frames into R, but I would like to copy images too.
The xlsReadWritePro version could do it (see code below). It's a
shareware package, but if people need/ask for a gratis license I send
it (please download and check ?xls.lic first; www.swissr.org). I'm
just finishing 'some' :-) RUnit tests and a new version will be
released tomorrow or after tomorrow.
Cheers,
Hans-Peter
rfile.img <- sub("origData", "origImage", rfile, fixed = TRUE)
wfile.img <- sub("tmpWriteData", "tmpWriteImage", wfile, fixed = TRUE)
pics <- c("pic1.jpeg", "pic2.png", "pic3.bmp", "pic4.emf", "pic5.wmf",
"pic.jpg")
fpics <- file.path(dirname(rfile), pics)
### test: image
### !!! tests have to be executed in sequencial order !!!
test.proImage.1write <- function() {
exc <- xls.open(rfile.img)
xls.image(exc, "set", fpics[1], "Pic1")
xls.image(exc, "set", fpics[2], "Pic2")
xls.image(exc, "set", fpics[3], "Pic3")
xls.image(exc, "set", fpics[4], "Pic4")
xls.image(exc, "set", fpics[5], "Pic5")
xls.image(exc, "set", fpics[6], c(17, 7, 20, 8))
xls.close( exc, file = wfile.img)
res <- xls.image(wfile.img, "list")
checkIdentical(res, c("Grafik 1", fpics))
}
More information about the R-help
mailing list