具体说下遇见的问题
1.shiny表格乱码的情况,因为使用的是shiny的DT包,找到相关的文档,谢大神给出的答案是library(htmltools),windows下可以在.Rprofile文件中添加Sys.setlocale(, 'Chinese')
2.shiny中使用ggplot2,坐标,图例和图内文字显示为乱码
首先想到的是编码问题,参照了http://blog.csdn.net/wlwlwlwl015/article/details/51482065 的方法折腾一晚上,没有搞定。早上的时候看到了http://cos.name/cn/topic/408656/ 但是不知道这段话该放在哪里,最终回到谢大神这里,windows测试没有问题,放在centos下还是挂掉了,查看
http://shiny.rstudio.com/gallery/unicode-characters.html
错误跑出的异常是
sh: locate: command not found
rm(font_home)
downloaded 0 bytes
Error in utils::download.file(url, method = method, ...) :
cannot download all files
In addition: Warning message:
In utils::download.file(url, method = method, ...) :
URL 'https://github-cloud.s3.amazonaws.com/releases/13722949/aca3ad44-1298-11e4-9499-2c2c4b1a1e74.ttc?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAISTNZFOVBIJMK3TQ%2F20160824%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20160824T024339Z&X-Amz-Expires=300&X-Amz-Signature=657ebda9fa7aec563592de13c160420b4013027a15f607a667a9e93159c2d7af&X-Amz-SignedHeaders=host&actor_id=0&response-content-disposition=attachment%3B%20filename%3Dwqy-zenhei.ttc&response-content-type=application%2Foctet-stream': status was '403 Forbidden
因为是内网环境,所以是没有配置代理的原因 ,R中设置代理的方法是
Sys.setenv(http_proxy="http://ip:port ″)
但是这个只对终端打开有效,线上的app还是不能用怎么办
分析了谢大的这段代码
font_home <- function(path = '') file.path('~', '.fonts', path)
if (Sys.info()[['sysname']] == 'Linux' &&
system('locate wqy-zenhei.ttc') != 0 &&
!file.exists(font_home('wqy-zenhei.ttc'))) {
if (!file.exists('wqy-zenhei.ttc'))
shiny:::download(
'https://github.com/rstudio/shiny-examples/releases/download/v0.10.1/wqy-zenhei.ttc',
'wqy-zenhei.ttc'
)
dir.create(font_home())
file.copy('wqy-zenhei.ttc', font_home())
system2('fc-cache', paste('-f', font_home()))
}
rm(font_home)
其实跟上面csdn博客中做的工作是类似的,既然访问不了github,那就下载传上去,然后执行这段命令,神奇般的能够显示了。
3.log地址 /var/log/shiny-server
4.部署:app文件放在/srv/shiny-server路径下就可以了
安装如下:
https://www.rstudio.com/products/shiny/download-server/
sudo yum install R
sudo su - \
-c "R -e \"install.packages('shiny', repos='https://cran.rstudio.com/')\""
$ wget https://download3.rstudio.org/centos5.9/x86_64/shiny-server-1.5.3.838-rh5-x86_64.rpm
$ sudo yum install --nogpgcheck shiny-server-1.5.3.838-rh5-x86_64.rpm
http://docs.rstudio.com/shiny-server/
管理:
$ sudo start shiny-server
$ sudo stop shiny-server
To restart the server you can run:$ sudo stop shiny-server $ sudo start shiny-server
No comments:
Post a Comment