[分享] R.cache套件分享
寫在R軟體club,也於此分享 R.cache一些簡單心得,希望R.cache多一點人用,
拋磚引玉一下
1. 套件名稱: R.cache
package info:
https://github.com/HenrikBengtsson/R.cache
2. 套件主要用途: 將執行R運算時,函數執行結果"記憶"起來,不必再重算
最近找適合在shiny app做cache,將某些計算過後的值記起來的package,並讓其他
session的使用者也用得到(加速),找到memoise、R.cache這兩個package。
相較之下,R.cache 因為它的cache (存在file system)是persistent,其他shiny
session會用一樣的cache (只要你給它的 key相同),但memoise每次在restart shiny
app都會重新建一個cache,也就是這個cache只能在同一session內重複被使用。所以在
shiny 環境下使用,R.cache成了不錯的選擇,但memoise其實提供不少功能,也許適用在
別的場合。
3. 套件主要函數列表:
有興趣玩玩看的,我提供一個小範例(app.R),放在 https://goo.gl/QXfLQv
但我只用到了其中兩個function: (其它請參考R.cache cran上的pdf)
a. saveCache() 顧名思義,將結果存入cache
b. loadCache() load結果出來
4. 其他:
實際應用在自己的shiny app,的確加速不少,適合應用在initial load,通常都是重複
的函數呼叫和計算。
值得一提的 R.cache的作者和 future package是同一位,做了相當多實用的package,但
似乎有點低調。R.cache的資訊很少。 R.cache 和 future 剛好在shiny上一個用在減少
intra-session delay,一個用在 inter-session (async)上
另外 shiny在更新到 1.2版時,提供了繪圖上的cache (renderCachePlot) 初步看介紹,
有點類似memoise 提供的一些功能,也許memoise也會有改版?
[關鍵字]:
shinyapp, R.cache, memoise
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.228.154.239
※ 文章網址: https://www.ptt.cc/bbs/R_Language/M.1541777889.A.FF6.html
推
11/10 00:17,
6年前
, 1F
11/10 00:17, 1F
※ 編輯: cywhale (36.228.154.239), 11/10/2018 00:45:12
推
11/10 15:46,
6年前
, 2F
11/10 15:46, 2F
推
11/10 22:07,
6年前
, 3F
11/10 22:07, 3F
→
11/10 23:28,
6年前
, 4F
11/10 23:28, 4F
→
11/15 20:44,
6年前
, 5F
11/15 20:44, 5F
→
11/15 20:45,
6年前
, 6F
11/15 20:45, 6F
R_Language 近期熱門文章
PTT數位生活區 即時熱門文章