Git "Pull" from within RStudio [closed] - r

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I am setting up an R project in RStudio (server version, if it makes a difference). I cloned the whole project from my Github account using git clone.
Problem:
Now I would now like to add a script that will do a Git pull command every time the user runs it in Rstudio.
The idea being that the user always have the most recent versions of all files in their project.
Goal
This seems easy enough to do using the graphical user interface (Click Git, pull branches) but I could not figure out how to do it in written code, something like
github_pull(branch)
I.e. it should replicate the git pull command I run in the terminal, but within the R script. Thus avoiding switching to the terminal. Is this possible?
The devtools package has a command of that name but it seems to be doing something different. I could not find anything on here or in the RStudio help either -- any pointers are much appreciated!
Solution
Based on #Mir Henglin 's spot-on solution below, here is what worked for me:
system("git pull")
However, this only worked if I initially cloned my repository using the ssh link (rather than https), as described here

See ?system and ?shell. These functions allow one to run shell commands from within R. I imagine you could call git pull pretty easily using those.
EDIT: Here is an example:
system('pwd')
/Users/mirhenglin/projects/R/
And
system('git pull --help')

Related

How could I transform data between several computers? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
Background: I want to build a simple distributed environment in R, which could do some "data massive" jobs in WINDOWS. For example, to calculate "big" matrix multiplication. There seem to have varies of solutions and I worked on them for a while, but I can't fix it.
I already tried these: Rserve & RSclient, packages such as snow, snowfall.
I tried several ways but I can't find a proper solution to transform data between clients, and it could be a disaster if all the data transform has to through the master.
Question: Is there any functions to deliver a matrix between every two computers as I want in a cluster?
I get an idea that maybe socket connection could work, but how can I start it gracefully? Should I have to start R script on different computers manually since there seems no SSH in the WINDOWS? I have to work on it because of my professor.
Wanted to know if it's good practice to do that? Thanks in advance.
You have the option to use would be using SparkR .
You will be compelled to use Spark APIs to distribute your data and there's a chance certain packages don't behave as expected but it would do the job.
A spark standalone cluster is made of a master accessible via HTTP and multiple workers. It's not the Ideal solution for resource sharing but it's lighter than a Hadoop + spark on yarn solution.
Finally you can try Dataiku as it can provide such ability via notebooks, spark integration and Dataset management . The community edition is not collaborative but they provide free license to schools

R machine learning model deployment as webservice [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
Is there any way to deploy machine Learning model written in R language as a webservice, I know we have Flask in python and many more too, but didnt come across for any such library for R Machine learning code.
As others suggested, you can use R-Shiny to build an app which you can later deploy as a web service easily. Moreover, you can use html code inside shiny so you can customise your layout to your heart's content. If you are using RStudio (which I definitely encourage if you don't), you only need to select File > New File > Shiny Web App... Have a look at documentation and examples here.
However, if you only want to create a compact and fast web service without having to build a layout etc, I would suggest you use R plumber library. This is a good solution if you don't need anything too fancy and also is easily implementable by adding decorators to your current code.
Hope this helps!

How to set up / configure R for a dev, stage, and production environment on one server? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
A colleague needs to set up a dev, stage and production environment on our server and he is asking what this means for how to run our R codes. Frankly, I do not know. My intuitive solution would be to have three different servers, so the installed R packages do not conflict. But for now, the environments should be on the same server. I am not sure how to achieve this. How can we run several versions of a package side by side? For example, using different .libPaths to be able to host different packages side by side?
What is the proper way to set this up?
PS. I hope I expressed myself clear enough, as I do not have any experience with this stuff.
Every GNU program allows you to prefix its installation (and more, as eg a suffix or prefix appended to the executable).
We use that in the 'how to build R-devel script' I posted years and and still use, directly and eg in the Dockerfile scripts for Rocker.
This generalizes easily. Use different configurations (with/without (memory) profiling, UBSAN, ...) and/or versions to you content, place them next to each other in /opt/R or /usr/local/lib/R or ... and just use them as every R installation has its own separate file tree. One easy way to access them differently is via $PATH, another is to just have front-end scripts (or shell aliases) R-prod, R-qa, R-dev, etc pp
You will have to think through of you want a common .libPaths() (for, say, common dependencies) or whether you want to reinstall all libraries for each. The latter is the default.

Run current line from vim in console (R, Matlab, Python, etc.) over SSH [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
I often find myself using SSH to remote into a server, and using tmux to split the terminal into two panes: editor (vim) and the console for either R/Matlab/Python, depending on which language I am working with. This way, I can perform some kind of analysis "interactively," and then use my mouse or tmux to copy the commands to my text editor so that I can make a script out of them.
This is quite inefficient, as I have to copy all the commands over to my text editor every time I run a command in the console. If I were working locally, I would open the Matlab GUI/IDE or R Studio, where I can write my commands in a script, and then execute them immediately after writing it with a convenient shortcut (e.g. cmd + enter) that will run the current line. This way, I can take advantage of the interactive terminal, while also building a script to replicate my work. But often I cannot do X forwarding, so the GUI IDEs are not available.
Is it possible to script vim and/or tmux to somehow run the current line from the editor in the open console session?
Please note that just saving and running the entire file is not a solution, because often the analysis takes significant amount of time, and I do not want to run everything from the beginning.
This is not the answer to the question, but just a suggestion with alternatives
1 - Install "RStudio Server" on the Server. Then you can use the GUI to maintain scripts and submit commands to the console.
2 - Use Notebook tools tools like Juypter with R kernel - https://github.com/IRkernel/IRkernel
Both allow code submission, script maintenance and graphics to be returned form the server to the webpage.
One solution, although not very elegant, would be to write a vim script that saves a temporary file with just the current line and runs that file. It would go something like
:.w temp.m
:!matlab temp.m
to extend with filetype awareness and such to your hearts content.

How do I access data from my personal computer on my AMI instance running RStudio server [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I have recently set up RStudio on an AMI ec2 instance using the process generously laid out by Louis Aslet from his website. But in an embarrassing turn of events I can't access the data I need because it resides on my personal computer. I am new to cloud computing and have 0 functional knowledge of Linux, but I do know SQL, and R well. Any help or suggestions would be greatly appreciated.
Have you tried the "Upload" button in the "Files" window of Rstudio?
use scp in terminal.
To put files from your remote server
Example: if the files are located locally in ~/mylocalfolder and you want to put them in /home/rstudio/mydata you would execute in terminal:
scp ~/mylocalfolder/*.csv ubuntu#<your address>:/home/rstudio/myData/
Note that if you want to access them under a different user, eg, rstudio, you need to change owners on the files. Use chown
To grab data from your remote server
Example: if the files are located on /home/rstudio/mydata and you want to put them locally in ~/mylocalfolder you would use
scp ubuntu#<your address>:/home/rstudio/myData*.Rda ~/mylocalfolder
I use the RStudio AMI all the time and what works for me is to use Dropbox. I can't remember exactly how I did it but I think I may have started the shell from within RStudio and installed Dropbox from the command line.
This link has a little more info:
http://www.louisaslett.com/RStudio_AMI/#comment-1041983219

Resources