I'm trying to produce a google motion chart in R slidify. I looked up a lot of examples online and it seems some people have successfully embedded google motion chart in an R slidify slide. Then when I tried my own using similar code, it gives me blank result. I also use the same method to produce a google pie chart and it works well (a pie chart shows in the plotting area)
Here is my simplified code below (Here I am using the Fruits dataset just like all other demo) :
---
title: "Title"
author: "Me"
date: '`r format(Sys.time(), "%d %B, %Y")`'
output:
ioslides_presentation:
incremental: yes
transition: default
widescreen: yes
slidy_presentation:
incremental: yes
job: Job Title
license: by-nc-sa
mode: selfcontained
hitheme: tomorrow
highlighter : highlight.js
subtitle: Subtitle
framework: io2012
widgets: []
---
## GoogleVis Motion chart example
```{r motionchartcode1, results='asis', warning=FALSE, comment=NA}
library(googleVis)
options(gvis.plot.tag='chart')
M <- gvisMotionChart(Fruits, 'Fruit', 'Year',
options=list(width=400, height=350))
#plot(M)
print(M, tag = 'chart')
```
---
## GoogleVis Pie chart example
```{r motionchartcode, results='asis'}
library(googleVis)
options(gvis.plot.tag='chart')
Pie <- gvisPieChart(CityPopularity,
options=list(width=400, height=200))
print(Pie, tag = 'chart')
```
Then I used slidify("demo.Rmd") to compile it to a html file. The first slide gives no plots but a blank plotting area.
I'm not sure which part is effecting this outcome: the setup in --- part, the options in r markdown chunk or my browser environment?
Hope someone can give me ideas.
The plot command in R uses the internal R http help server to overcome this limitation.
Here's how I overcame it:
Go to
http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html
Click on the dropbox which says 'Edit location' and choose 'add location'
Click 'browse for folder or browse for file'
Choose the folder (or file) in which was your saved html output
Click OK
Also you can modify your codes, for example I did:
suppressPackageStartupMessages(library(googleVis))
options(gvis.plot.tag='chart')
M1 <- gvisMotionChart(Fruits, idvar="Fruit", timevar="Year")
plot(M1)
print(M1, file="myGoogleVisChart.html")
Now open your googleVis html file and it should display successfully.
In fact, any googleVis file you open from within the folder you selected will also display as you would expect.
Please note that I am using MS Internet Explorer and it asked me to activate ActiveX before I was able to view the output from above, and it was working for me.
Still, if you can not see then also please check for :
https://cran.r-project.org/web/packages/googleVis/vignettes/googleVis.pdf
Related
I've finished a lovely R Markdown script with an HTML output and was excited to share the analysis to colleagues internally, by sharing the Sharepoint link.
The output works fine when I open the HTML file directly on my machine. But for whatever reason, when I share or view via the Sharepoint link, simple things like the TOC, plotly graphs and leaflet maps do not render.
Here's an example of the problem I'm running into, with some really basic script just as an example.
---
title: "Test_Output"
output:
html_document:
toc: true
toc_float: true
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## R Markdown
Hello, this is a test.
## Test
```{r test plotly, echo = FALSE, warning = FALSE, message = FALSE}
library(plotly)
plot_ly(data = iris, x = ~Sepal.Length, y = ~Petal.Length)
```
And so this is the output, right.
But when I share the link (something like this https://mycompany.sharepoint.com/:f:/s/mydepartment/EvLlZjmxOetc)
or if someone were to try and just navigate to the page on our Sharepoint, the output is all messed up. It looks like this: plots and TOC and maps do not render.
If anyone can help me to figure out how to allow my Markdown HTML output to render instantly once I share the link, that would be incredible, and I would feel like all my work on the script was not in vain!
I've tried adding "download=1" to the end of the URL, which indeed gives users an ability to view the output correctly by clicking the link and downloading the HTML, but this is not optimal as this is supposed to be a live product that I will continue updating.
Turns out that a solution is to rename your HTML file to aspx. Then, when you provide the link to users in your organisation, they can easily view it.
I am new to R markdown and tried to use it on my computer at work. However, I was not able to change the theme or add tabs. On my personal computer, however, everything works and I get pretty HTML documents.
I used the markdown document that opens every time you open a new document. I changed the html theme to lumen and included tabs:
## I want tabs {.tabset}
### Tab 1
```{r cars}
summary(cars)
```
### Tab 2
You can also embed plots, for example:
```{r pressure, echo=FALSE}
plot(pressure)
```
#{-}
Here I have some screenshots of the tab sections:
My laptop:
My computer at work:
my computer at work is not able to create the Tabs and is als not changing the font if I change the theme... If someone has suggestions on how to fix this, that would be great!
EDIT: Could it be an issue with the path? Since IT installs R for all computers the Pathvarible instead of "C:/Programms" is "\user01\User\username\Programms" I set the global PATH of R Studio to "C:/..." but if I knit the document in R Markdown, it still uses the weird path for the library path...
I wanted to just write a comment, but I don't have enough reputation for that. You can try to remove and re-install the yaml package and see if it helps.
But it would be good to get more information from you. Do you have an older version of R in your working computer? Apparently this was a known bug back in 2018. See Tabs not rendering when knitting rmarkdown to html. In this case the problem was solved by re-installing the yaml package and installing the dev version of Rmarkdown devtools::install_github('rstudio/rmarkdown').
Edit: Trying using package flexdashboard
---
title: "My tabs"
author:
output:
flexdashboard::flex_dashboard
---
## I want tabs {.tabset}
### Tab 1
```{r cars}
summary(cars)
```
### Tab 2
You can also embed plots, for example:
```{r pressure, echo=FALSE}
plot(pressure)
```
Good luck!
This is the first time I am using rmarkdown to knit a document into an html output. I see the output as an html document, no problem. However the output is linked to my personal working directory (example:file:///C:/Users/e337384/table_formatting.html).
---
title: "Inter-Rater Agreement (Long Beach)"
output:
html_document: default
word_document: default
date: "2/6/2020"
---
```{r,echo=FALSE, message=FALSE}
library(knitr)
require(kableExtra)
library(tidyverse)
options(knitr.table.format = "html")
```
I would like to be able to share the html document with my team, but since the output is linked to my drive only I can see it. How do I save this output in a way that allows me to share this html output?!
Recently, the export mechanism for files has changed slightly.
Now you have to check the corresponding check-box of the file you wish to export and then select More -> Export, as shown in this picture:
I have a Wordpress website for my podcast, www.ghccpod.com, and have produced an r-markdown script for it. I try to render it using RWordPress and knit2wp, but the out of the file has several issues, none of which I can find good solutions on this site. The one I want to ask about here is how to get the css tabs working when uploading the rmd as a wordpress post
I have the following code
---
title: "The Global Childhood Cancer Puzzle is Taking Shape"
subtitle: "The new view from the edge"
output:
html_document:
mathjax: default
---
knitr::opts_chunk$set(echo = FALSE)
knitr::opts_chunk$set(warning = FALSE)
knitr::opts_chunk$set(message = FALSE)
knitr::opts_chunk$set(error = FALSE)
library(tidyverse)
library(data.table)
library(readxl)
library(rethinking)
library(janitor)
library(gramr)
library(plotly)
library(kableExtra)
library(knitr)
library(waffle)
library(gganimate)
library(ggpol)
library(ggforce)
library(cowplot)
library(magick)
library(gghighlight)
library(RWordPress)
### {.tabset .tabset-fade .tabset-pills}
#### Fig. 1 - tab
(its not quoted in the document - I can't figure out how to get stackoverflow to display the #)
some code
Then I will load it onto my website using RWordPress:
library(RWordpress)
library(knitr)
options(WordpressLogin = c(myusername = 'mypassword'),
WordpressURL = 'https://www.ghccpod.com/xmlrpc.php')
knit2wp('test.RmD',
title = 'Test Post',
publish = FALSE,
action = "newPost")
When I load it onto my website using something similar to the above code I get this abomination: (password is test) - https://www.ghccpod.com/the-global-childhood-cancer-puzzle-is-taking-shape-edge-1/
Among other problematic output on my page, I get this ugly code thing:
{.tabset .tabset-fade .tabset-pills}
some code
My question is how do I get the tabs to display properly (it works when I knit the rmd to an html document and load that into my browser). Thank you so much for your help.
I am producing a HTML report output using R and when i get the output html file and open it I can see the charts i created using ggplot no problem but if i send the html file to anyone else the charts are missing and they only see the text. My code is below, any advice on what I am missing would be great.
Also i have an image from my local drive that isn't showing up.
---
title: "title"
``author:
- "X"
date: "`r format(Sys.time(), '%d %B %Y')`"
output:
html_document:
number_sections: yes
toc: yes
runtime: shiny
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE,message=FALSE, warning=FALSE)
```
{r libraries, include=FALSE}
library(plyr)
library(dplyr)
library(tidyverse)
library(ggplot2)
library(forcats)
library(reshape)
library(png)
```{r, fig.width=12, fig.height=6, fig.align="center"}
# read in data file
lj= read.csv("LJ_Final.csv") # read csv file
#rename variables to fit charts
names(lj)[names(lj) == "2015"] <- "15"
myvars <- c("HB","15")
newdatajoiner <- lj[myvars]
newdatajoiners.long<-melt(newdatajoiner,id.vars="HB")
aggdatajoiners <-aggregate(value ~ HB + variable, data =
newdatajoiners.long, sum)
#plot the data
aggdatajoiners%>%
ggplot(aes(x=variable,y=value,fill=factor(HB)))+
geom_bar(stat="identity",position="dodge")+
labs(x="", y="")+
theme_bw()+
facet_wrap(~HB)
```
```{r,fig.align="center",out.width = "3000px"}
knitr::include_graphics('./tablefife.png')
```
#user3018495 The other thread describes how to exclude the charts. To include the charts in the output HTML document, one sets self_contained to yes rather than no in the Rmd output options.
---
title: "your title goes here"
output:
html_document:
self_contained: yes
toc: yes
toc_float: yes
---
If you are using RStudio with knitr, this is configured in RStudio options. First select the gear in the code editor window.
Next, select the Advanced tab, and
click Standalone HTML
then press `OK'.
When you knit the document the resulting HTML file will contain the charts, as illustrated by a test HTML document that I posted in a Github repository so it can be viewed by the Github HTML Previewer.
regards,
Len
When your HTML is generated from the Markdown file an image folder is generated with the HTML, your images are referenced by the HTML, not included in the html file itself, You need to send this folder as well.
You could convert the image to a base64 string and embed in the html file, however I don't know how to do that automatically in R