无法使用“保存为”函数以保存生成的.CSV文件并将其编译为Windows OS上的zip文件
我遇到问题,使该代码正常工作。
当我单击ShinyApp中的“结果表”按钮时,生成的文件最终位于我的app.r文件所在的同一文件夹中。出现保存作为函数的保存,但事实证明该函数已过时。该功能在Linux上起作用,但在Windows上不起作用,我无法弄清楚其背后的原因。
这是一个小故障吗?如果是这样,还有另一种编写代码在Windows上解决此问题的方法吗?
有人告诉我这是窗户上的小故障,但是那是一段时间,我想检查是否有更好的方法编写代码以使其正常工作。
代码:
#Download Results tables
output$downloadTable <- downloadHandler(
options(scipen = 999),
filename = function(){
"chromosome_count_tables.zip"
},
content = function(file){
compare_tbl_list <- compare_all(files = dataPlotInputBAMSegment(),
ref = ReferenceInputBAMSegment(), window = T,
per = T, compare_from_normal = FALSE)
segment_plot_tbl_all <- segment_tbl_create_all(compare_tbl_list)
segment_annotation_tbl_all <- segment_annotation_tbl_create_all(segment_plot_tbl_all)
segment_annotation_tbl_all <- change_color_all(segment_annotation_tbl_all)
final_tbl_all <- show_table_all(files = segment_plot_tbl_all, annotation_files = segment_annotation_tbl_all)
files <- NULL;
#loop through the sheets
for (i in 1:length(final_tbl_all)){
#write each sheet to a csv file, save the name
fileName <- paste(input$fileBAMSegment[i,1],"_",i,".csv",sep = "")
write.csv(final_tbl_all[i],fileName,row.names = F)
files <- c(fileName,files)
}
#create the zip file
system2("zip", args=(paste(file,files,sep=" ")))
}
I am having issues getting this code to work properly.
When i click on the save "results table" button in my ShinyApp, the files generated ended up in the same folder where my app.R files is located. The save as function appears , but it turns out that that function is obsolete. This function worked on Linux but not on Windows and I couldnt figure out the reason behind this.
Is this a glitch and if so , is there another way of writing the code to fix this issue on Windows?
I was being told that it is a glitch on Windows but it was a while back and I would want to check if there is a better way to write the code to get it to work properly.
Code:
#Download Results tables
output$downloadTable <- downloadHandler(
options(scipen = 999),
filename = function(){
"chromosome_count_tables.zip"
},
content = function(file){
compare_tbl_list <- compare_all(files = dataPlotInputBAMSegment(),
ref = ReferenceInputBAMSegment(), window = T,
per = T, compare_from_normal = FALSE)
segment_plot_tbl_all <- segment_tbl_create_all(compare_tbl_list)
segment_annotation_tbl_all <- segment_annotation_tbl_create_all(segment_plot_tbl_all)
segment_annotation_tbl_all <- change_color_all(segment_annotation_tbl_all)
final_tbl_all <- show_table_all(files = segment_plot_tbl_all, annotation_files = segment_annotation_tbl_all)
files <- NULL;
#loop through the sheets
for (i in 1:length(final_tbl_all)){
#write each sheet to a csv file, save the name
fileName <- paste(input$fileBAMSegment[i,1],"_",i,".csv",sep = "")
write.csv(final_tbl_all[i],fileName,row.names = F)
files <- c(fileName,files)
}
#create the zip file
system2("zip", args=(paste(file,files,sep=" ")))
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我只想在这里更新,我设法自己解决了它。
该代码只有在通过浏览器而不是通过Windows OS中的观看器窗格或Rstudio查看器打开ShinyApp时才能使用。它在Ubuntu正常工作。
请参阅:如何下载使用R Markdown创建的多个报告和r zip文件中的闪亮
PS:不确定您是否还需要安装rtools并将其添加到DevTools 包裹。
以防万一需要,您可以参考:
https:// rstats.wtf/set-up-an-r-dev-environment.html 和
https://ohdsi.github.io/hades/rsetup.html#:~: text = your%20Start%20Menu.--,,,installing%20Rtools;
I would just want to update here that I managed to resolve it on my own.
The code will only work if you open the shinyapp through a browser and not through the viewer pane or Rstudio viewer in Windows OS. It works normally in Ubuntu.
Refer to : How to download multiple reports created using R markdown and R shiny in a zip file
PS: Unsure if you need to also install RTools and add it to your devtools package.
Just in case it is needed , you can refer to :
https://rstats.wtf/set-up-an-r-dev-environment.html and
https://ohdsi.github.io/Hades/rSetup.html#:~:text=your%20Start%20Menu.-,Installing%20RTools,Select%20the%20default%20options%20everywhere.