在Shiny中无法打开连接 [英] cannot open the connection in Shiny

查看:224
本文介绍了在Shiny中无法打开连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有
我正在尝试在Shiny应用程序中将数据框写入RDS文件。我正在使用下面的代码。

  AgName<  -  gsub(\\ s,,paste(mtrl1,'_',stage1 ,'_',sample1,'。RDS',collapse =''))
saveRDS(Input_Data2,AgName)

但是它是抛出以下错误信息:

 错误:无法打开连接

相同的代码在R命令行上运行良好,但在Shiny应用程序中不能运行。任何帮助将不胜感激。谢谢!






感谢Flick!

  setwd(/ opt / shiny-server / samples / sample-apps / P-AG粘贴(mtrl1,'_',stage1,'_',sample1,'。csv',collapse ='')
AgName< - gsub(\\ s, '))
saveRDS(Input_Data2,file = AgName)






感谢Flick!

你说得对。目录没有对directy的写权限,我正在试图写。再次感谢嘘!

解决方案

我得到同样的问题。我提到了这个问题,并使用下面给出的代码来解决这个问题。我用这个代码,它运行正常:

  wrtfun2< -reactive({
if(!is.null (输入$ var1))
setwd(/ opt / shiny-server / samples / sample-apps / test)
sink(outfile.txt)
cat(input $ var1 )
sink()
}

我试图写的目录的权限,它终于工作。

All, I am trying to write a data frame into RDS file in Shiny app. I am using below code.

AgName <- gsub("\\s","",paste(mtrl1,'_',stage1,'_',sample1,'.RDS', collapse = ' '))
saveRDS(Input_Data2, AgName )

But it is throwing following error message:

Error: cannot open the connection

Same code is running fine on R command line but not in Shiny app. Any help will be highly appreciated. Thanks!


Thanks Flick!

I used below code as well, but no luck.

setwd("/opt/shiny-server/samples/sample-apps/P-AG-Disc4/")
AgName <- gsub("\\s","",paste(mtrl1,'_',stage1,'_',sample1,'.csv', collapse = ' '))
saveRDS(Input_Data2, file=AgName )


Thanks Flick!

You were right. Directory was not having write permission on the directy, where I was trying to write. Thanks again soo much!

解决方案

I was getting the same issue. I referred to this question and used the below given code to resolve this. I used this code, and it ran fine:

  wrtfun2<-reactive({
  if (!is.null(input$var1))
  setwd("/opt/shiny-server/samples/sample-apps/test")
  sink("outfile.txt")
  cat(input$var1)
  sink()
  }
)

I also changed the permission on the directory where I was trying to write and It worked finally.

这篇关于在Shiny中无法打开连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆