I've created a single R file 'myfile.R' which is composed of several functions, reading from an odbc connection, and of course the ui and server components for the shiny application. The goal is for the user to treat this as an executable, that is, I'd like them to be able to run this app without having to run Rstudio. Currently on this environment, Rstudio is installed (as are the relevant packages), what I'm currently writing in command line is:
Rscript myfile.R
The file looks to be successfully loaded, but the application itself does not 'pop up' towards me, infact nothing does, it just says that it is listening on http....
I was thinking of creating a bash script that could do this, and this seemed to be the most simple approach but this is not working.
Related
I am new to R and Rstudio and currently trying to figure out a few things that would easen switching too much between the linux-terminal and the file navigating system. As I prefer using the former I would therefore like a method that allows me to open .R files in R studios in-built editor but directly via the linux terminal. I have tried to illustrate what I want on the attached picture. Does this functionality exist? So far I have only been able to execute R scripts via the terminal.
I have trawled through the web trying to find a similar question but they all seem to be related to executing R scripts via the terminal rather than opening them in the Rstudio editor.
My colleague and I are trying to run an R script on a virtual machine we both have access to. We're trying to run it in the command line of the virtual machine (long story, task scheduler etc..), and the actual script lives in a Onedrive location we both have access to (if you wonder why the file paths look different, its the same file location in each, different mapping).
I'm able to run the script and Tidyverse loads:
It runs into an unrelated error inside the script where it can't open a file, but that's not pertinent to this question. The relevant info here is that I can run it, and when it runs its able to successfully load Tidyverse
My colleague runs the exact same commands and receives this error:
It says that she can't load Tidyverse because there is no package called that.
We've both separately made sure that Tidyverse was installed. I.e. we'll be logged into the Virtual machine, we'll open RStudio and/or RGui (we've each done both) and install.packages("Tidyverse") and it'll install into this location for each of us:
So my question is:
Why does Tidyverse load when I run it, but not when my colleague does?
I have a basic shiny app (ui.r and server.r) that I am able to run in RStudio.
But seems like I can't run it in IntelliJ.
I have installed the R language support plug-in and I can run r scripts.
But when I try to run ui.r, the only thing I get is html output in the console.
Does anyone recognise this? I probably forgot to configure something?
I do have experience running java (web) apps with IntelliJ. With tomcat setup e.g.
In the run configurations, I didn't see anything specific for a shiny server or something R related. So I guess that is not where I should search ...
Any idea? Is more information needed?
Thx in adavance.
edit:
The answer is here: https://youtrack.jetbrains.com/issue/R-895
To run a shiny App (R framework) on PyCharm you must enable R first and indicate where is the R interpreter located:
R options appears on the bar status. One of them is R Console. Click on it. Write getwd() command to see if you are in the root directory of the project. If not, set it with setwd() command:
Next, write runApp() and DO NOT press enter yet. You must press alt+enter and then click on load Shiny:
I am used to using R in RStudio. For a new project, I have to use R on the command line, because the data storage and analysis are only allowed to be on a specific server that I connect to using ssh. This server doesn't have rstudio-server to support remote RStudio sessions.
The project involves an extremely large dataset, and some pre-written code to load/format the data that I have been told to run using "source()" before I do anything else. This takes several minutes to run and load the data each time.
What would a good workflow be for something like this? Editing my code in a .r file, saving, then running it would require taking several minutes to load the data each time. But just running R in an interactive session would make it hard to keep track of what I am doing and repeat things if necessary.
Is there some command-line equivalent to RStudio where you can have an interactive session but be editing/saving a file of your code as you go?
Sounds like JuPyteR might be your friend here.
The R kernel works great.
You can use it on a remote server either with exposing an open port (and setting up JuPyteR login credentials)
Or via port forwarding over SSH.
It is a lot like an interactive reply, except it holds state.
And you can go back and rerun cells.
(Of course state can be dangerous for reproduceability)
For RStudio you can launch console and ssh to your remote servers even if your servers don't use expensive RStudio for servers platform. You can then execute all commands from R Studio directly into the ssh with the default shortcut key. This might allow to continue using R studio, track what you're doing in the R script, execute interactively.
I would like to pass a PostgreSQL connection object (which is an RObject) to a batch process. Is this possible at all?
Why am I trying to do this?
I had trouble running a script that sources another script on R Studio Server. The script itself runs fine without the other script sourcing it. So this is clearly an R Studio Server Web Interface issue. However I am trying to circumvent the issue by just triggering a batch from R Studio server, after I used its nice .rs.askForPassword function that ships with Rstudio. I tried to following but couldn't get it to work cause to connection always ending up being expired when it was used from the batch.
# run file
save(con,file="conObj.Rdata")
system("R CMD batch.R") # also tried Rscript
batchfile looks like this
# batch file
load("conObj.Rdata")
#.... run some db query #
save("someObjFromDb","test.Rdata")
This breaks because of an expired connection object.