Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

投稿: 一个访问量高达 1300 万的 shiny 应用的诞生故事 苏玮 #907

Merged
merged 31 commits into from
Sep 14, 2020

Conversation

swsoyee
Copy link
Contributor

@swsoyee swsoyee commented Sep 1, 2020

非常感谢您的PR, 如果您是在为主站投稿, 请将PR的标题改为"投稿:标题+作者的形式",如:
"投稿: 数据通灵术 杜亚磊"
并保留下面的内容.

  • 投稿者请注意
    • 主编审核确认接收
    • 主编安排审稿人
    • 审稿、修改

至此,投稿部分的工作结束

  • 编辑部分工作
    • 文字编辑做校对工作。需校对文章分类,目前的文章分类包括:COS访谈,R会议,R语言,推荐文章,新闻动态,机器学习,统计之都,统计图形,统计应用,统计模型,统计计算,统计软件,职业事业。不得擅自增加分类。
    • 微信编辑、发布,阅读原文附主站链接,文末附作者介绍
    • 论坛帖子负责人发帖,粘贴链接,提供 forum_id 加入文章
    • 合并 PR,发布文章

投稿指南在这里,有任何问题,可以直接在PR留言,其他问题请联系: editor@cos.name

@yufree
Copy link
Collaborator

yufree commented Sep 1, 2020

感谢投稿,不知轩哥 @yixuan 有时间看下吗?

@yufree
Copy link
Collaborator

yufree commented Sep 7, 2020

湘云有空看下这篇吗?@XiangyunHuang

@XiangyunHuang
Copy link
Member

@yufree 好的👌,这周末我会审一下

- 可视化
- shiny
- dashboard
forum_id: InfinityLoop
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

论坛 ID forum_id 就用帖子 https://d.cosx.org/d/421731-covid-19dashboard 对应的 ID 怎么样?@Perfectizer
论坛 ID 和帖子链接的对应关系就是前面这一串数字,比如这里的 421731

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 68ca7df

forum_id: InfinityLoop
---

本文主要分享一下我从1月底开始的一个用`shiny`制作的用来关注日本疫情动态的项目。项目本身为日文版`(https://covid-2019.live/)`,然后5月份左右开始逐步翻译成中`(/cn)`英文`(/en)`版本。项目所有代码和数据集全部开源[swsoyee/2019-ncov-japan](https://github.com/swsoyee/2019-ncov-japan)。只要Clone到本地,安装完所有需要的软件包即可本地启动。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shiny 之类的 R 包名称可以统一加粗 shiny,链接可以用一对尖括号包住 https://covid-2019.live/

英文类的字词,比如 Clone 可以汉化为克隆, commit 可以汉化为提交, dashboard 可以汉化为仪表盘,除了专有名词(比如 Github)外,建议尽量少中文英文混杂,下同

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 3a27054 2b9b6f6


本文主要分享一下我从1月底开始的一个用`shiny`制作的用来关注日本疫情动态的项目。项目本身为日文版`(https://covid-2019.live/)`,然后5月份左右开始逐步翻译成中`(/cn)`英文`(/en)`版本。项目所有代码和数据集全部开源[swsoyee/2019-ncov-japan](https://github.com/swsoyee/2019-ncov-japan)。只要Clone到本地,安装完所有需要的软件包即可本地启动。

需要注意的是由于项目开发是本人利用工作之余时间赶制而成,我本人也不是R语言老手和shiny应用开发老手,代码质量和项目结构可能极其恐怖(能用就行),各位吐槽时希望能嘴下留情。如果大家能帮忙提出改进的PR当然是最好的了!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

作者大可不必这么谦虚,这么谦虚的话,我都要无地自容了。我相信大部分人第一眼看到的时候还是很惊艳的,会很想知道作者是怎么做到的,将想法变成一款数据产品。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 3a27054

Copy link
Member

@XiangyunHuang XiangyunHuang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

总体上,作为一款 shiny 打造的数据产品,给人眼前一亮的视觉冲击是本文最显著的特色!其次,对于想要掌握背后技术的人,相信会毫不犹豫地去看作者的源码仓库。

另外文笔不好请大家多多包涵。文章对废话进行了标注,各位跳着看即可。

这个dashboard经过了数次迭代(GitHub的commit数量高达7000多次,去掉数据更新的类的commit外大概有数千次都是功能改善的结果),到现在它长成了下面这个样子:
![Figure1](https://raw.githubusercontent.com/swsoyee/2019-ncov-japan/doc/www/doc/img/Figure1.png)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

文字和图之间需要空行,这样更加美观,作者不妨看看预览效果 https://deploy-preview-907--cosx.netlify.app/2020/09/covid19-bulletin-board/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 68ca7df

2. 在尽可能多维度展示数据上下功夫;
3. 注重动态互动,处理好疫情时间轴。

**下面主要是一些详细的个人思考流程,废话比较多不感兴趣的各位可以直接跳过。**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

本段和下面那段都不是废话,很体现数据思维,甚至可以说是商业思维。数据收集、组织、管理是打造数据产品的基石,数据源头的可靠性、收集的规范性、组织的科学性、管理的合理性直接决定数据产品的开发效率以及应用价值


## 应用逻辑

可能对于一些老手来说下面的这些可能是初级问题,但由于非应用开发专业的前生信专业的渣渣的我来说也走过这个坑,作为经验还是想分享给大家,应用开发老手可以直接跳过。简单来说:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不管读者是高级用户还是初级用户,建议全把他们当作小白来介绍。


##### 1.2.4 确诊矩形树图

在很多疫情dashboard中,通常采用地图的形式展示每个地区的确诊人数情况(可用`leaflet`实现),但每个国家的所发表的确诊患者的详细程度不同,比如国内包括香港的dashboard可以实现精确到小区和楼栋,而日本通常最细只能获取到区级范围的信息,如果使用地图来展现的化,坐标定位就会是一个很大的问题,因此在这里我使用了矩形树图来进行可视化。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

处处体现了作者数据驱动的思维,选择合适的图形来展示数据并不是人人都具备的能力


![Figure17](https://raw.githubusercontent.com/swsoyee/2019-ncov-japan/doc/www/doc/img/Figure17.png)

接下来是PCR检测人数、康复和新冠咨询热线的接线情况等。在`echarts4r`下支持图例点击(显示/隐藏)效果,而在切换的过程中会有**默认过渡动画**效果,个人认为这一点比`plotly`更为出色。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议单独开辟一节的篇幅介绍在整个项目的技术实现过程中积累起来的宝贵经验。建议正文主要以图文并茂的方式陈述功能、内容、想法和创意,借助数据思维给大家讲一个故事。

@XiangyunHuang
Copy link
Member

另外,有一个问题就是 shinydashboardPlus 包的函数 descriptionBlock() 的参数非兼容性变化,比如 number_color 要变成 numberColor 等,详见
https://github.com/RinteRface/shinydashboardPlus/blob/master/NEWS.md

后来,也注意到作者 @swsoyee 已经在处理这个问题了,是否有可能在文章正式发出前修复这个问题?

@XiangyunHuang
Copy link
Member

关于文章标题,我觉得作者不妨再斟酌一下,目前标题有些平淡,内容实则非常硬核,我先抛个砖,比如 如何打造访问量高达 1300+ 万的企业级 shiny 应用

@yihui @yufree 不妨也来围观一下


![Figure21](https://raw.githubusercontent.com/swsoyee/2019-ncov-japan/doc/www/doc/img/Figure21.png)

右侧为一个关于确诊患者去向的Sankey图。用于显示每日确诊患者的流向(症状的有无轻重、是否在住院、出院和死亡等信息)。但由于厚生劳动省所发表的数据格式有过多次变更,而上述信息已经不再进行详细公布,因此这个Sankey图可以说已经可有可无了。待以后有时间再进行修正。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sankey图可以改为桑基图

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 8459a69


##### 1.2.5 详细数值栏

在全国数据总览的`box`中的底部,使用`shinydashboardPlus`的`DescriptionBlock`制作了一排用于展示主要数据的底栏。一开始出于全面展示日本境内的疫情状况(包括医疗资源应对等)的目的,同时将公主号游轮的数据纳入了统计范围当中了(根据WHO的标准,公主号游轮单独进行了统计而不并作日本的数据)。因此在这里为了说明这一情况,把日本国内的计数和游轮进行分开统计以免造成误解。此外使用`shinyBS`中的`bsTooltip`进行一些额外信息的加注。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 建议全文 R 包都加粗表示,比如 shinydashboardPlus
  • 建议 R 函数都用一对反引号包裹,且加一对英文小括号 (),比如 DescriptionBlock()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in e0f103b

@swsoyee
Copy link
Contributor Author

swsoyee commented Sep 13, 2020

借地传图
スクリーンショット 2020-09-13 23 25 41 図1

@swsoyee
Copy link
Contributor Author

swsoyee commented Sep 13, 2020

@XiangyunHuang 感谢黄编辑,我已润色完毕,shinydashboardPlus的版本升级不兼容问题也已经解决。

@XiangyunHuang
Copy link
Member

@swsoyee 太好了!我去安排人编辑一下微信端

@XiangyunHuang XiangyunHuang changed the title 投稿:用shiny和echarts4r制作一个COVID-19的dashboard 苏玮 投稿: 一个访问量高达 1300 万的 shiny 应用的诞生故事 苏玮 Sep 14, 2020
@XiangyunHuang
Copy link
Member

@swsoyee 愿意提供个人介绍吗?我们会在主站和微信端的文末介绍,具体话术类似我们网站的成员页面,非常灵活

@swsoyee
Copy link
Contributor Author

swsoyee commented Sep 14, 2020

@swsoyee 愿意提供个人介绍吗?我们会在主站和微信端的文末介绍,具体话术类似我们网站的成员页面,非常灵活

好的,我稍微想想然后在这里留言?

@XiangyunHuang
Copy link
Member

@swsoyee 可以直接提交PR修改成员数据文件 https://github.com/cosname/cosx.org/blob/master/data/members.yaml, 它是个 YAML 格式,插入的位置根据你的姓名的拼音字母顺序来

@XiangyunHuang
Copy link
Member

@swsoyee 微信端已经编辑好了,这是预览

@swsoyee
Copy link
Contributor Author

swsoyee commented Sep 14, 2020

@XiangyunHuang 感谢!我也追加添加了自己的个人信息

@XiangyunHuang
Copy link
Member

@swsoyee 👍,那我们晚上8点半,正式推送啦!

@Perfectizer 麻烦微博也同步推广一下

@XiangyunHuang
Copy link
Member

@yufree 那我先合并到主库了,生成正式主站链接,微博可以下午或晚上都可以发

@XiangyunHuang
Copy link
Member

@yihui @yufree 今天,我和编辑在微信端编辑文章的时候,发现文章中的图片挺多,都是以 Github 作为图床,国内,比如人大校园访问就会出现问题。

@yixuan 我们是不是该刷一波文章的图片,复制一份存到自己的库里了。今后是否可以设置一个定时任务自动化这个过程

@XiangyunHuang XiangyunHuang merged commit ca1168a into cosname:master Sep 14, 2020
@XiangyunHuang
Copy link
Member

@swsoyee @yufree 因为这篇文章已经在其它微信公众号平台发布过,现在不是原创了,微信后台只允许转发了。

@swsoyee
Copy link
Contributor Author

swsoyee commented Sep 14, 2020

@XiangyunHuang 居然有这种事……这个版本明明更新的😭正文也修改了这么多,不好意思给大家添麻烦了……

@XiangyunHuang
Copy link
Member

@swsoyee 微信后台检测相似度很高,不能以原创文章发出来

@yufree
Copy link
Collaborator

yufree commented Sep 14, 2020

印象中微信转载时可以做一定修改吧?是不是要开白名单之类,以后已经微信原创的文章再投主站应加上白名单放行的要求。

@XiangyunHuang
Copy link
Member

文章若在其它媒体上发过,应该提前告知我们,这样也可以提前和相关媒体联系获取权限

@swsoyee 你是否可以联系之前发过的公众号,让他们给我们开通微信公众号的白名单,把修订版本发出去。你方便加我的微信号吗?我的是 Sophorae

@swsoyee
Copy link
Contributor Author

swsoyee commented Sep 15, 2020

@XiangyunHuang @yufree 非常抱歉给大家添麻烦了。我已经邮件联系之前的公众账号开放白名单看能不能把修订版发出去了。
@XiangyunHuang 已加微信。

文章若在其它媒体上发过,应该提前告知我们,这样也可以提前和相关媒体联系获取权限

另:或许是否考虑把这个添加到PR模版中去更方便一下。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
主站日常管理
  
Awaiting triage
Development

Successfully merging this pull request may close these issues.

None yet

3 participants