Why cannot I call the app when I save the R script as app.R into the working directory? - r

First of all I set my working directory as following
setwd("C:/Users/asus/Desktop/App-1")
Then I can call the app with the following code:
runApp("C:/Users/asus/Desktop/App-1")
But I cannot call the app via :
runApp("App-1")
The script in the directory is named as "app.R" but it appears in the directory as "app".
Whereas, in the R webpage it says if I create a new directory named App-1 it should have worked. But It does not. Many thanks.

Related

How to use 'shinytest' with 'golem'?

I'm new to 'golem'. So far I did my Shiny apps as packages, with the app in the folder inst/app, and then to use 'shinytest' I made a folder inst/app/shinytest. How to do with 'golem'? There's no app folder: inst/app only contains www, and the UI and the server are some functions in the package.
So I need to know where to put the 'shinytest' script and how to deal with 'testthat' and the expect_pass function? (I don't want to use testServer)
I've found. It suffices to create a file app.R in the app folder with these contents:
mypackage::run_app()

How to put an R script into a dockerfile?

I am trying to add my R script into a dockerfile. The beginning of the file (loading base image, installing necessary packages) works fine when I run it in my terminal, but I keep getting this error when it gets to the line that contains the R script I want to run:
Step 15/17 : COPY /Users/emma/Documents/folder1/examples/question-1/model-1.r .
COPY failed: stat /var/lib/docker/tmp/docker-builder376572603/Users/emma/Documents/folder1/examples/question-1/model-1.r: no such file or directory
I am already running the terminal out of the "question-1" directory (my shell command looks like this) :
Emmas-MacBook-Air-2:question-1 emma$
and the R script file "model-1.r" is in that folder. What am I doing wrong in detailing the path to the R script? Do I have to somehow transform the script before adding it to the dockerfile?
Thank you
I believe, that you have to specify relative (to your build folder) path to copy from. Source:
Multiple resources may be specified but the paths of files and directories will be interpreted as relative to the source of the context of the build.
And file to copy should be inside context of the build. So if your Dockerfile is located in folder A, then the objects you would like to copy should be placed in the folder A or it's subfolders.

The output directory is under your source tree in meteor

how do I solve this
The output directory is under your source tree
warning:the output directory is under your source tree
your generated files may get interpreted as source code
consider building into a different directory instead meteor build ../output
I apologize for my ignorance on this matter, I am new in the world of programming and meteor. about my case. 1. I have a folder on Desk called “Findme” where I have the structure of my project (the code and everything which forms the application which works) 2. Then through the console I access that directory findme and then run the command meteor build/Desktop/MyApp --server = https: //findme.com, and start downloading. 3. But inside the console I also get the message indicated before and when it is finished, and I check the folder MyApp, it is empty. 4. And when I check the Findme folder it has created a folder named ~ and inside displays a file called Desktop/MyApp but it also doesn’t have any useful files, only winrar and nothing useful. 5. I am trying to generate the apk, could you please let me know what I might be doing wrong? Is there another way to generate the apk? I would appreciate it if you could help me!
Your should specify a path for where to build your application that is outside of your project directory.
Otherwise this can lead to problems with Meteor's file watcher and as your error already pointed out:
your generated files may get interpreted as source code consider
building into a different directory instead
So if your command uses a relative path, as used in meteor build ../output then it is important to call this command at the most upper project folder.
Consider the following project structure:
/myapp
/client
/import
/server
If you call meteor build ../output from within /myapp it will generate the output folder as expected outside of the project:
/output
/myapp
/client
/import
/server
However if you call it from within a subfolder, say /myapp/imports it may generate the output within the project like so:
/myapp
/client
/import
/output
/server
So keep this in mind when building your app.
Further readings:
https://guide.meteor.com/deployment.html#custom-deployment
https://docs.meteor.com/commandline.html#meteorbuild

R shiny: Retrieve home directory of a shiny app

Is there a function or a way to retrieve the path of root home directory of a shiny app?
The shiny app I run creates multiple directories and changes working directory. But at point in the app, I need to jump to the home directory. getwd() won't work unless I run it first and save it as a variable or something.
I am thinking of something like the below command used to read a file from a package home directory on any platform without knowing the actual path.
#get root dir
system.file()
# read a file from the root dir of a package
a <- system.file("bla",package="foo")
The approach has to work locally, on shiny-server and shinyapps.io. (In situations where I cannot set the path manually).

Why my app doesn't deploy on shinyapps.io?

I followed the same commands shown in shinyapps.io for uploading my app but I get the following error:
> library(shinyapps)
> shinyapps::deployApp("/Users/mona/CS764/demo")
Error in lint(appDir) : Cancelling deployment: invalid project layout.
The project should have one of the following layouts:
1. 'shiny.R' and 'ui.R' in the application base directory,
2. 'shiny.R' and 'www/index.html' in the application base directory,
3. An R Markdown (.Rmd) document.
Here's the structure of my files:
When using deployApp() you must deploy the directory containing your ui.R and server.R files (or shiny.R / www/index.html if using a custom UI). The files can not be a subdirectory.
Additionally, its important to note that any R files in the directory or any subdirectory will be parsed, so its important that they have valid syntax.

Resources