R shinyapp.io で web アプリをデプロイしてみた
はじめに
こちらの記事で簡単な R のアプリを試作してみた。これをshinyapps.ioを使ってデプロイしてみる。無料で5つまでのアプリケーションなら作成可能。
ユーザー登録
E-mail アドレスかgoogle ID, GitHub IDを使ってログインできる。メールアドレスでログインした場合、「Please verify your email address」のメールが届き、アドレスの確認を求められる。URLをクリックして登録が完了する。
パッケージのインストールとアプリの登録
Dashboard上の案内に従ってアプリの登録までを行ってみる。
STEP 1 – INSTALL RSCONNECT
アプリのデプロイにはrsconnect
というパッケージが必要なよう。これをRコンソールからインストールする。
install.packages("rsconnect")
STEP 2 – AUTHORIZE ACCOUNT
アカウントの承認が必要なよう
The rsconnect package must be authorized to your account using a token and secret. To do this, click the copy button below and we'll copy the whole command you need to your clipboard. Just paste it into your console to authorize your account. Once you've entered the command successfully in R, that computer is now authorized to deploy applications to your shinyapps.io account.
rsconnectパッケージは、トークンとシークレットを使用してアカウントに承認する必要があるそう。承認を行うための必要なコマンドがクリップボードにコピーされるので、それをRコンソールに張り付けるだけでアカウントを承認できる。このコマンドを入力することで、そのコンピューターが shinyapp.io アカウントにアプリケーションを展開する許可を与える。
という事なので、実行してみる。
rsconnect::setAccountInfo(name='ryamamoto0406', token='XXXX', secret='XXXX')
特に戻り値などは無いよう。
STEP 3 – DEPLOY
Once the rsconnect package has been configured, you're ready to deploy your first application. If you haven't written any applications yet, you can also checkout the Getting Started Guide for instructions on how to deploy our demo application. Run the following code in your R console.
rsconnectパッケージを構成すると、最初のアプリケーションをデプロイする準備が整う。 まだアプリケーションを作成していない場合は、デモアプリケーションをデプロイする方法について、スタートガイドを確認することもできる。 Rコンソールで次のコードを実行する。
との事なので、こちらの記事で作ったアプリをデプロイしてみる。
library(rsconnect)
rsconnect::deployApp('path/to/your/app')
Preparing to deploy application...DONE
Uploading bundle for application: 3733328...Detecting system locale ... ja_JA
DONE
Deploying bundle: 4298703 for application: 3733328 ...
Waiting for task: 882670952
building: Processing bundle: 4298703
building: Building image: 4915666
building: Installing packages
building: Installing files
building: Pushing image: 4915666
deploying: Starting instances
rollforward: Activating new instances
success: Stopping old instances
Application successfully deployed to https://ryamamoto0406.shinyapps.io/shiny_app/
となり、自動でデプロイできた。作ったアプリは https://ryamamoto0406.shinyapps.io/shiny_app/ でアクセスができる。
おわりに
shinyapp.io を使って簡単にアプリをデプロイすることができた。特に知識などは必要なかったので、今度はAWSなどの環境に shiny を導入し動かしてみる事などに挑戦してみたい。また、アプリも複雑なものを作っていきたいとも思う。
Author And Source
この問題について(R shinyapp.io で web アプリをデプロイしてみた), 我々は、より多くの情報をここで見つけました https://qiita.com/ryamamoto0406/items/0244daa7e99339c1eeb5著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .