Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Export both Image and Data from R to an Excel spreadsheet

Tags:

r

excel

It is simple to print an image and save it on disk just:

fit <- lm(some ~ model)

png(filename="your/file/location/name.png")
plot(fit)
dev.off()

Write some data to a excel spreadsheet just

write.csv(rnorm(10),"some file",sep=",")

My question is how would one redirect both the above in to a spreadsheet. Another word, output a graph paired withs some image/plot on to a excel workbook?

Thanks,

like image 789
user1234440 Avatar asked Nov 30 '22 01:11

user1234440


1 Answers

I would use the xlsx package. Check out the addPicture function and the addDataFrame function. I found this package fairly easy to work with.

like image 139
rrs Avatar answered Dec 05 '22 16:12

rrs