モーダルをロゴ (png 形式) で表示する Shiny モジュールをパッケージ化しようとしています。この目的のために、ロゴ ファイルを保存する「inst/www」ディレクトリを作成しました。ディレクトリ ツリーは次のようになります。
├─ DESCRIPTION
├─ inst
│ └── www
│ └── logo.png
├── man
│ └── test.Rd
├── NAMESPACE
├── packagetest.Rproj
└── R
└── test.R
ただし、ビルドしてインストールした後、パッケージは「logo.png」を配置した事前定義されたディレクトリから読み取られないようです。代わりに、パッケージから関数を挿入したメイン プロジェクトから読み取ります。パッケージの testUI() 関数は次のようなものです。
testUI <- function(id) {
ns <- NS(id)
shiny::showModal(
modalDialog(
title = img(src="inst/www/logo.png", style="display:block; margin-left:auto; margin-right:auto;"),
br(),
fluidRow(
column(6, align="center", offset = 3,
textInput(ns("username"), label = NULL, placeholder = "Username"),
passwordInput(ns("password"), label = NULL, placeholder = "Password")
)
),
footer = (
fluidRow(
column(6, align="center", offset = 3,
actionButton(ns("signin"),"Sign in")
)
)
)
)
)
}
私が他のプロジェクトで見たものから、「inst」フォルダーは行くべき道のようですが、私はまだRパッケージに慣れていないので、自分が何をしているのかよくわかりません. これに関するヘルプは大歓迎です、ありがとう!