Referencing this question, when I install RSS I specify my R executable by putting the output of which R into my /etc/rstudio/rserver.conf file as rsession-which-r=<path to R.
Is there a way I could have a different value for that for different users?
Related
I am writing a user-friendly function to import Access tables using R. I have found that most of the steps will have to be done outside of R, but I want to keep most of this within the script if possible. The first step is to download a Database driver from microsoft: https://www.microsoft.com/en-US/download/details.aspx?id=13255.
I am wondering if it is possible to download software from inside R, and what function/package I can use? I have looked into download.file but this seems to be for downloading information files rather than software.
Edit: I have tried
install_url(https://download.microsoft.com/download/2/4/3/24375141-E08D-
4803-AB0E-10F2E3A07AAA/AccessDatabaseEngine_X64.exe)
But I get an error:
Downloading package from url: https://download.microsoft.com/download/2/4/3/24375141-E08D-4803-AB0E-10F2E3A07AAA/AccessDatabaseEngine_X64.exe
Installation failed: Don't know how to decompress files with extension exe
Before I invest too much time in it I need to know... Do R Markdown Parameterized Reports require an R Studio Connect server?
If they do that's a little outside of my budget and what I want to get into.
I'd like to be able to send out static .html files people can upload their data.csv into, and another .html file will be spit out based off my scripts and R Markdown.
Parametrized Rmarkdown reports are a feature provided by the rmarkdown package (>= version 0.8). They do not require a RStudio Connect Server. However, you will still need a running R process somewhere to render the report based on the provided parameters.
I created a local R-package (gmad) on one computer. I want to copy this package to a server and continue developing it.
I have the "project folder" in my current working directory where I wrote the R code etc. (includes the R functions explicitly saved in separate files).
There is also a folder with the same name in the directory containing all the installed packages - which has a sub-dolder named "R" but unlike the previous folder, it does not contain separate files for different functions. I'm guessing this is the "installed" version of the package and that I won't be able to modify the R code in it.
What is the best way to copy this to the new computer. On the original computer, .libPaths() shows two locations for installed packages. I don't really care about these on this machine however I want to follow the correct procedure for the server. What is the best practice - should there be only one location and if so, what should it be?
I want to pass secure parameters to shinyapps.io deployment so my application could get them via:
Sys.getenv('PASSWORD_X')
I cannot find anything for this in deployApp function in the rsconnect package.
You can use Renviron.site or .Renviron to store and access private data into your shiny application. (see here for Hadley Wickham's recommendations and instructions - ref example below).
Solution:
Storing API Authentication Keys/Tokens (Attribution: Hadley Wickham)
If your package supports an authentication workflow based on an API key or token, encourage users to store it in an environment variable. We illustrate this using the github R package, which wraps the Github v3 API. Tailor this template to your API + package and include in README.md or a vignette.
Create a personal access token in the Personal access tokens area of
your GitHub personal settings. Copy token to the clipboard.
Identify your home directory. Not sure? Enter normalizePath("~/") in the R
console.
Create a new text file. If in RStudio, do File > New File >
Text file.
Create a line like this:
GITHUB_PAT=blahblahblahblahblahblah
where the name GITHUB_PAT reminds you which API this is for and blahblahblahblahblahblah is your personal access token, pasted from the clipboard.
Make sure the last line in the file is empty (if it isn’t R will silently fail to load the file. If you’re using an editor that shows line numbers, there should be two lines, where the second one is empty.
Save in your home directory with the filename .Renviron. If questioned,
YES you do want to use a filename that begins with a dot ..
Note that by default dotfiles are usually hidden. But within RStudio, the file browser will make .Renviron visible and therefore easy to edit in the future.
Restart R. .Renviron is processed only at the start of an R session.
Use Sys.getenv() to access your token. For example, here’s how to use your GITHUB_PAT with the github package:
library(github)
ctx <- create.github.context(access_token = Sys.getenv("GITHUB_PAT"))
# ... proceed to use other package functions to open issues, etc.
FAQ: Why define this environment variable via .Renviron instead of in .bash_profile or .bashrc?
Because there are many combinations of OS and ways of running R where the .Renviron approach “just works” and the bash stuff does not. When R is a child process of, say, Emacs or RStudio, you can’t always count on environment variables being passed to R. Put them in an R-specific start-up file and save yourself some grief.
I am facing difficulty in integrating R with Tableau.
Initially when I created calculated field it was asking for Rserve package in R and was not alowing to drag field to worksheet. I have installed this package but still it shows error saying
"Error occurred while communicating with the Resrve service.Tableau i unable to connect to the service.Verify that server is running and that you have access privileges"
Any inputs. Thank you
You need to start Rserve. If you successfully install Rserve package, simply run this (on RGui, RStudio or wherever you run R scripts)
> library(Rserve)
> Rserve()
You can test your connection to RServe on Tableau, on Help, Settings and Performance, Manage R Connection.
As of Tableau 9, you can use *.rdata files with Tableau. Tableau 9 will read the first item stored in the *.rdata file. Just open an *.rdata file under "Statistical Files" in the Tableau intro screen.
To do this do:
save(myDataframe, "Myfile.rdata")
This will save the file with the dataframe stored in it. You can save as many items as you want, but Tableau will only read the first. It can read vectors and variables as well if they are in the first item. Note that rdata files compress data quite a bit. I recently compressed 900mb to 25mb. However Tableau will still need to decompress it to use it so be careful about memory.