2017-03-06 87 views
0

我希望能够将图像下载为图像(PNG或JPEG)。让我们假设我的数据帧是DF将图像下载为图像r

output$statsTable <- renderTable({ 
    #Printing the table 
    df 
}) 

output$downloadStatsTable <- downloadHunter(
    filename = function() { 
     paste(getwd(), '/test.png', sep = '') 
    }, 

    content = function(con) { 
     p <- grid.table(df) 
     device <- function(..., width, height) grDevices::png(..., width = 12, height = 9, res = 300, units = "in") 
     ggsave(file, plot = p, device = device) 
    } 
) 
+1

你的问题是什么?你的代码不工作?你会得到什么错误? –

+0

问题是我有一个按钮,点击时会下载表格的图像,我不知道该怎么做。上面的代码不会工作,因为没有下载的情节。 – wittywillis

回答

0

下载表格作为图像可以使用grid.table功能从库gridExtra。这里是您可以用作模板的代码:

​​

希望它有帮助!