knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" ) options(datatable.print.nrows = 100, datatable.print.class = F)
牛白血病ウイルス(BLV)の農場内での感染の広がり方をシミュレーションするパッケージです。
R、RStudioおよびRtoolsをインストールしていない場合、まずそちらをインストールする。
インストール方法参考:
次に、RStudioで次のコードを実行することで、このパッケージをインストールする。
# 初回のみ install.packages("remotes") remotes::install_github("fmsan51/blvibmjp")
file.path(.libPaths()[1], "blvibmjp")
フォルダ内の input.xlsx を適当な場所にコピーして、牛・牛舎・移動などのデータを入力する。
(とりあえず適当なデータでシミュレーションを試したい、という場合は同フォルダ内のテスト用データ(input_test.xlsx)を使ってみてください。)
以下のようなコードを実行する。
# パッケージの読み込み library(blvibmjp) # シミュレーションの設定 param$simulation_length <- 60 # シミュレーション期間の長さ(月) param$n_simulation <- 3 # シミュレーション回数 param$output_dir <- "result" # シミュレーション結果の保存フォルダ # 対策の設定 param$control_insects <- 0.3 # 吸血昆虫対策を行っている場合、対策により吸血昆虫がどれだけ減少するか(0.3=30%に減少(7割減)) param$change_gloves <- TRUE # 直検手袋を毎回交換するか(TRUE/FALSE) param$feed_raw_colostrum <- FALSE # 凍結・加温処理していない初乳を子牛に与えているか # 他、詳細は help("param") 参照
# データの入力 data <- prepare_data( "C:\\Users\\xxx\\Desktop\\input.xlsx", # データを入力したファイルの場所 param)
param$output_dir <- "inst/extdata/readme_output" data <- prepare_data("inst/input_test.xlsx", param)
# シミュレーションの実行(1回ごとに十数秒~数分) simulate_blv_spread(data, param)
output <- file.path(getwd(), param$output_dir) output
plot_prev(param, language = "Japanese") # 陽性率の推移 plot_route(param, language = "Japanese") # 感染原因別頭数 calc_prev(param, type = "prop") # 月ごとの感染率 calc_prev(param, type = "count") # 月ごとの感染牛頭数 calc_prev(param, type = "status") # 月ごとの感染ステージ別頭数(s=非感染、ial=感染・無症状、ipl=持続性リンパ球増多症、ebl=地方病性牛白血病)
write.csv(calc_prev(param, type = "prop"), file.path(output, "prev.csv")) # 表をcsvに保存(保存場所は 4. で表示されたフォルダ)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.