0

I am using the R programming language. I am following a tutorial here on making an interactive dashboard with the famous iris data set : https://beta.rstudioconnect.com/jjallaire/htmlwidgets-rbokeh-iris/htmlwidgets-rbokeh-iris.html

I copy and pasted the source code (after installing the necessary libraries):

---
title: "rbokeh iris dataset"
author: "Ryan Hafen"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    social: menu
    source_code: embed
---

```{r setup, include=FALSE}
library(rbokeh)
library(flexdashboard)
```

Column {data-width=600}
-----------------------------------------------------------------------

### Species

```{r}
figure(width = NULL, height = NULL) %>%
  ly_points(Sepal.Length, Sepal.Width, data = iris, color = Species)
# figure() %>%
#   ly_points(Sepal.Length, Sepal.Width, data = iris,
#     color = Species, glyph = Species)
```


Column {data-width=400}
-----------------------------------------------------------------------

### Species (Quantile)

```{r}
figure(width = NULL, height = NULL, legend_location = "top_left") %>%
  ly_quantile(Sepal.Length, group = Species, data = iris)
```

### Petal Width

```{r}
figure(width = NULL, height = NULL) %>%
  ly_points(Sepal.Length, Sepal.Width, data = iris,
    color = Petal.Width)
```

And this produced many errors:

> Column {data-width=600}
Error: unexpected '{' in "Column {"
> -----------------------------------------------------------------------
+     
+     ### Species
+     
+     ```{r}
Error: attempt to use zero-length variable name
> figure(width = NULL, height = NULL) %>%
+     ly_points(Sepal.Length, Sepal.Width, data = iris, color = Species)
> # figure() %>%
> #   ly_points(Sepal.Length, Sepal.Width, data = iris,
> #     color = Species, glyph = Species)
> ```
Error: attempt to use zero-length variable name
> 
> 
> Column {data-width=400}
Error: unexpected '{' in "Column {"
> -----------------------------------------------------------------------
+     
+     ### Species (Quantile)
+     
+     ```{r}
Error: attempt to use zero-length variable name
> figure(width = NULL, height = NULL, legend_location = "top_left") %>%
+     ly_quantile(Sepal.Length, group = Species, data = iris)
> ```
Error: attempt to use zero-length variable name
> 
> ### Petal Width
> 
> ```{r}
Error: attempt to use zero-length variable name
> figure(width = NULL, height = NULL) %>%
+     ly_points(Sepal.Length, Sepal.Width, data = iris,
+               color = Petal.Width)
> ```
Error: attempt to use zero-length variable name

This produces all the plots individually, e.g :

enter image description here

But it does not produce an "interactive dashboard" as produced from the website. Can someone please show me what I am doing wrong?

Thanks

stats_noob
  • 5,401
  • 4
  • 27
  • 83
  • 1
    Have you tried removing spaces from author and title? – Ronak Shah Mar 14 '21 at 03:46
  • I just tried that right now. It didn't work. I also tried removing them all together and it still didnt work. Did you mean the spaces after the ":" ? Thank you – stats_noob Mar 14 '21 at 03:52
  • 1
    https://stackoverflow.com/questions/46171362/rmarkdown-error-attempt-to-use-zero-length-variable-name – Sleepy Miles Mar 14 '21 at 04:03
  • Thank you, I saw this post and I am trying to understand the many answers provided here and how they apply to my question. So far, I am still confused... – stats_noob Mar 14 '21 at 04:07
  • @ronak shah: if you have time, can you please show me how i could fix this code? Thank you – stats_noob Mar 14 '21 at 04:53
  • 1
    Copying your code as it is in an Rmd flexdashboard file and knitting it with `Knit to flexdashboard` works for me without any error. – Ronak Shah Mar 14 '21 at 05:07
  • @RonakShah: I entered this line of code to create a new "Rmd flexdashboard file" : rmarkdown::draft("dashboard.Rmd", template = "flex_dashboard", package = "flexdashboard") . I copy and pasted the original code and clicked "save". I then tried to preview the file by entering this code : rmarkdown::run(input = "dashboard.Rmd", output_format = "html_document") ... but I got an error: Error in rmarkdown::run(input = "dashboard.Rmd", output_format = "html_document") : unused arguments (input = "dashboard.Rmd", output_format = "html_document") ... do you know what I am doing wrong? thank you – stats_noob Mar 14 '21 at 05:23
  • Is it possible to save the final product as a "html" file? – stats_noob Mar 14 '21 at 05:26
  • @RonakShah : I continued to work on this question and posted a related question here: https://stackoverflow.com/questions/66621723/r-converting-rmarkdown-to-html-files can you please take a look at if you have time? thank you – stats_noob Mar 14 '21 at 06:31
  • I just encountered this error. It was caused by trying to do various dplyr manipulations when one of the columns in the table actually had an empty string "" for a column name. I located the cause of this upstream and it fixed the problem. If you can check any intermediate steps, I'd recommend inpsecting the table you're trying to plot, and ensure that no spurious columns were added, or any names removed. – Aidan Morrison May 30 '22 at 06:20

0 Answers0