Hello, I have written a R script which runs a regression of a dataset and saves the result in a csv file. Now this dataset has to be edited periodically which is done in a server. I need to run the R script in a server so that the results can also be shared in a server and used in a web application. I have coded in R and have used R in windows. I have never used Ubuntu/Linux. Is there a step by step guide on how to run a R code in server? Thanks and Regards, Swagato
Running R in Server
6 messages · Swagato Chatterjee, John McKown, Loris Bennett +1 more
2 days later
On Sun, Aug 16, 2015 at 3:27 AM, Swagato Chatterjee <swagato1987 at gmail.com> wrote:
Hello, I have written a R script which runs a regression of a dataset and saves the result in a csv file. Now this dataset has to be edited periodically which is done in a server. I need to run the R script in a server so that the results can also be shared in a server and used in a web application. I have coded in R and have used R in windows. I have never used Ubuntu/Linux. Is there a step by step guide on how to run a R code in server? Thanks and Regards, Swagato
I
? was going to answer yesterday, but work went insane. Also, I was hoping
someone else had something, because I don't have any "step by step"
instructions.
This is a rather complicated question. So I'm going to ask a number of
questions and make some statement for you to correct, if necessary.?
?Statement: You have a Windows desktop and have used R on it, so you are
familiar with R in a Windows environment.?
Statement: You are not Linux (Ubuntu) trained.
Statement: You wrote an R script on Windows, which works, but you need to
run it on Ubuntu.
The above is my starting point. Now I have some questions.
Can you connect to the Ubuntu server from your Windows desktop? If so, how?
If not, I'm confused about how you could get anything to run on the Ubuntu
server.
Where does this "dataset" reside? On you desktop? On a Windows shared
folder? On the Ubuntu server? Other?
Who or what edits the "dataset"? That is, is it always yourself? Some one
in your group? Some other human? Some automated process?
Why can't you run the R script as you do now, then deploy the results to
the Ubuntu server? Since I don't know the environment that the Ubuntu
server runs in, I can't address how to deploy an updated file into it. I
assume you have some sort of deployment software. It could be as easy as
being able to ftp the results from your desktop to the proper places on the
Ubuntu server.
?===
Now, whatever the answers are to the above, you'll likely need some help
from your Ubuntu server people. My first approach, given my ignorance,
would be that I would have something set up so that you could edit this
"dataset" on your desktop (assuming that's what you do). I would then have
you ftp it ?to a special directory on the Ubuntu server set up especially
for this function. Now, what remains would be running the R script, likely
in a "shell script" (like a PowerShell command file), whenever you do the
ftp. There is a function in Ubuntu (any Linux) called "icrond". This is a
daemon (Windows service equivalent) which can "monitor" a file or directory
for changes. When a change is detected it can take an action. In this case
it would be to schedule the execution of the previously mentioned "shell
script". The "shell script" would then take the actions necessary to do the
R script ("R CMD script-name parameters ..." for instance) and then deploy
the results to the web server (however you normally do this). Setting up
the icrond environment is going to take some work by your Ubuntu
administrator.
===
I hope this was at least the start of some help to you.
Schrodinger's backup: The condition of any backup is unknown until a restore is attempted. Yoda of Borg, we are. Futile, resistance is, yes. Assimilated, you will be. He's about as useful as a wax frying pan. 10 to the 12th power microphones = 1 Megaphone Maranatha! <>< John McKown [[alternative HTML version deleted]]
Swagato Chatterjee <swagato1987 at gmail.com> writes:
Hello, I have written a R script which runs a regression of a dataset and saves the result in a csv file. Now this dataset has to be edited periodically which is done in a server. I need to run the R script in a server so that the results can also be shared in a server and used in a web application. I have coded in R and have used R in windows. I have never used Ubuntu/Linux. Is there a step by step guide on how to run a R code in server? Thanks and Regards, Swagato
If you are lucky, you can just copy your script to the server and call Rscript /path/to/your/r/script on the linux command line. However, you'll probably have to make sure that all the packages you need are installed on the server. HTH Loris
This signature is currently under construction.
On Sun, Aug 16, 2015, 2:29 PM Swagato Chatterjee <swagato1987 at gmail.com> wrote: Hello, I have written a R script which runs a regression of a dataset and saves the result in a csv file. Now this dataset has to be edited periodically which is done in a server. I need to run the R script in a server so that the results can also be shared in a server and used in a web application. Have a look at deployR on Revolutioanalytic website. There is a free open-source solution for windows. I have coded in R and have used R in windows. I have never used Ubuntu/Linux. Is there a step by step guide on how to run a R code in server? Thanks and Regards, Swagato ______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Dear all, Thenks for replying to my query. *@Amaud: If I understand correctly what you want to do, you might be able to create a HTML report using RMarkdown and host that on the website. If you really need a web app, I suggest looking into Shiny. You can make a shiny app, host it for free on the cloud. You will have a lot to learn, but it will be time well spent. https://www.rstudio.com/ <https://www.rstudio.com/>* Obviously I have shiny as an option.But I was thinking PHP based GUI is a better fit for me as I have very limited resources in my team who can create a Shiny app and implement it with the all the functionalities of a PHP based GUI. *Have a look at deployR on Revolutioanalytic website. There is a free open-source solution for windows.* I'll check this. *@John: Statement: You have a Windows desktop and have used R on it, so you are familiar with R in a Windows environment.?* *Statement: You are not Linux (Ubuntu) trained.* *Statement: You wrote an R script on Windows, which works, but you need to run it on Ubuntu.* *The above is my starting point. Now I have some questions.* *Can you connect to the Ubuntu server from your Windows desktop? If so, how? If not, I'm confused about how you could get anything to run on the Ubuntu server.* My developer has given me an username and password which I can use to connect the server using Putty. The GUI is being developed in Ubuntu server only using PHP and my the results of my RScript (figures and tables) will be the input of the GUI. Having said that, I have limited knowledge how to implement the R and run the script in server after loggin in to the server. *Where does this "dataset" reside? On you desktop? On a Windows shared folder? On the Ubuntu server? Other?* Right now, on my desktop. But soon the dataset will be residing on a server. *Who or what edits the "dataset"? That is, is it always yourself? Some one in your group? Some other human? Some automated process?* The input data of my Rscript again comes from another app and the database is also residing on the same server. The update of the dataset is being done by the app automatically. *Why can't you run the R script as you do now, then deploy the results to the Ubuntu server? Since I don't know the environment that the Ubuntu server runs in, I can't address how to deploy an updated file into it. I assume you have some sort of deployment software. It could be as easy as being able to ftp the results from your desktop to the proper places on the Ubuntu server.* I cannot run the R script as I do now because the Rscript will also be called for automatically so that the results of the Rscript go as an input to the end app. PFA the architecture picture. *@Loris: However, you'll probably have to make sure that all the packages you* *need are installed on the server.* This is where I need a help.? Thanks and Regards, Swagato
1 day later
Swagato Chatterjee <swagato1987 at gmail.com> writes:
*@Loris: However, you'll probably have to make sure that all the packages you* *need are installed on the server.* This is where I need a help.?
Presumably the program 'cron' will be used to run your script. If the
program is run as root, you will have to ask the admin of the server to
install the packages you need. If you have a cron entry for your user
on the server, you can simply start R and install the packages in your
home directory with
install.packages(c("pkg1", "pkg2"))
Note that this could fail if your server is behind a firewall and unable
to access a CRAN mirror.
HTH
Loris
This signature is currently under construction.