gvisMotionChart is not working in R markdown file - r

I need to embed gvisMotionChart into an R markdown file and find an example interactive which is really helpful. However when it comes to the googlevis plotting I keep getting this error when I press the "run code" button:
connection to openCPU failed:
error
undefined
NetworkError: A network error occurred
Can anybody figure out the solutions?
Thanks in advance.

The googleVis package creates the javascript that has to be embedded into an HTML document in order for the interactive plot to run on a webpage. You won't be able to get it to work in the console or in Rstudio for that reason. The only way to know for sure if it's working is to knit it to HTML, and then publish it to Rpubs (or anywhere else online). Once it is online it will work. Depending on your browser settings, you might be able to get it to work by opening the HTML locally, but the browser often blocks the embedded plot when opened locally.
Without seeing your actual code, I can't provide you with anything more specific than that.
EDIT: I thought I would add that several months ago I made a markdown file detailing interactive plots in R for a class. You can find it here: http://rpubs.com/crmhaske/uwloo670_Interactive_Plots
If you scroll down to the very end you'll see the example I did using gvisMotionChart. You have to make sure the place where you print the graph is in it's own chunk, and that results is asis:
```{r results='asis'}
print(p,'chart')
```

Related

Link chrome to Rstudio for pagedown (Rmarkdown)

I want to convert my html document, created on Rmarkdown to pdf.
One of the way is to use the pagedown package.
However, when I add:
knit: pagedown::chrome_print
in the yaml header, I get the error:
Error in find_chrome() : Cannot find Google Chrome or Edge automatically from the Windows Registry Hive.
Please pass the full path of chrome.exe or msedge.exe to the 'browser' argument
or to the environment variable 'PAGEDOWN_CHROME'.
However, i have no idea on how to link the Chrome browser to rstudio, or where can I access to 'PAGEDOWN_CHROME'.
I tried:
knit: pagedown::chrome_print(browser="C:/Users/johndoe/AppData/Roaming/Microsoft/Windows/Start Menu/Programs"
which is the path to Chrome but the knitting systematically hangs without giving an error.
I am sure this is an easy procedure but but I'm a beginner at this stuff.
I've done a lot of research on SO and the internet, but obviously everyone knows how to do it !
Thanks :-)

Rmarkdownon Kaggle: Can you spot what's going on?

it's been a few days that im trying to run my Rmd on Kaggle, but it simply doesn't work.
The main reason (I guess) is that, somehow the console is reading the code as an R code, but im sure that I'm using Rmarkdown.
Therefore, the console reads a Text line as a code line, giving me the code error below:
Also, i tried to copy and edit other's people markdown, but i keep getting the same error line.
You can check my code here: https://www.kaggle.com/badluckmath/kernel4c85aae59c/edit/run/39891200
He's working perfectly on my Rstudio.
I'm looking for a huge help here, please!
I've been stuck with this for a week!
If i press the buttom to run code, it will simply give me this error message.
For that, i still don't know the solution. But since this is a premade Rmarkdown and i knew that it works, i simple used the Save (Commit) options and at the end, it worked.

R Markdown not showing execute button for other engines

In R Markdown if I have a chunk coded with the normal r chunk wrappers,
```{r}
[R code]
```
A play button will appear. However, when I run a chunk wrapped like so for other language engines:
```{python}
[python code]
```
or replacing python replaced with bash/sh, I don't get a play button on the right.
Is there a package I need to install? I restarted Rstudio, and even downloaded the Lesson 5: https://rmarkdown.rstudio.com/lesson-5.html , which even shows those play buttons, and I still don't get it. I am on a mac, and saw that someone on a Windows computer was able to see the play buttons.
I think you need to install the package "knitr". Try to check that first.
Second, you might need to state explitly where your interpreter for Python is, for instance. Use
{python, engine.path = '/usr/bin/python3'}
YOUR CODE
to see if it works.

Rstudio Global Changes: show chunk output in console via CLI?

How can I force RStudio (v1.1.383) to evaluate R chunks always in console (instead of inline) when working with Rmarkdown documents, using a script?
I know I can set up Output chunks in Console by clicking on it:
According to this RStudio support post I could also un-check 'Show output inline for all R Markdown document' under 'Tools -> Global Options...':
But, is there a way to do it from a command line?
The reason I ask is that, I often work on my university machines and they all restore to defaults after each reset. Each time when in class, we have to manually go thru menus.
Knowing how to do it via a console command would as useful as starting each of my classes with
rm(list=ls())
There's not currently an elegant way to do this. This preference is stored inside an internal RStudio state file, in %localappdata%\RStudio-Desktop\monitored\user-settings. If you're sufficiently motivated you can write a script which sets the rmd_chunk_output_inline preference, but it's going to be unpleasant.
One thing you can do is set the chunk output type in the YAML header, like this:
---
editor_options:
chunk_output_type: console
---
You could also use an R Markdown document template with this set up for you (maybe your script could write this out).
Finally, there's an open issue for this on RStudio's github page which you might comment on and/or vote for:
https://github.com/rstudio/rstudio/issues/1607

R Studio Convert .RMD to pdf

all
Ufff... I believe I did my hw to research this and still don't have an answer so asking all:
I have R-Studio, valid RMD file, when I tried to I don't get new .pdf file, I have viewer which is still html.
No problem to create HTML, it works fine, but I need pdf.
tried to use render ("file.RMD", "file.PDF") to find that I don't have render, tried install pandoc, got an error < package ‘pandoc’ is not available (for R version 3.1.2)>
so what is the simple way to get that pdf, why my doesn't work as desinged? what I'm missing I put that info into header too...
output: pdf_document
Im totaly lost, appreciate help.
render("Proj1.RMD", "Proj1.pdf")
Best
Mario

Resources