My reprex not working, please help.

I was generating reprex for this code:

library(ggplot2)
library(plotly)

# using mpg data set, already loaded as a part of ggplot2

fig<-plot_ly(mpg,x=~cty, y=~hwy, 
             color=~drv,
             frame = ~class,
             type="scatter",
             mode="markers")
fig

but then it showed me this error
This reprex appears to crash R. See standard output and standard error for more details.

Standard output and error

e[31m✖e[39m Install the e[34mstylere[39m package in order to use `style = TRUE`.
Error : Functions that produce HTML output found in document targeting gfm-yaml_metadata_block output.
Please change the output type of this document to HTML. Alternatively, you can allow
HTML output in non-HTML formats by adding this option to the YAML front-matter of
your rmarkdown file:

  always_allow_html: true

Note however that the HTML output will not be visible in non-HTML formats.

This should run

library(ggplot2)
library(plotly)

fig <- plot_ly(mpg, x = ~cty, y = ~hwy, 
               color = ~drv,
               frame = ~class,
               type = "scatter",
               mode = "markers")

# plot
show(fig)
# press PLAY

I get that, too.

library(ggplot2)
library(plotly)
#> 
#> Attaching package: 'plotly'
#> The following object is masked from 'package:ggplot2':
#> 
#>     last_plot
#> The following object is masked from 'package:stats':
#> 
#>     filter
#> The following object is masked from 'package:graphics':
#> 
#>     layout

# using mpg data set, already loaded as a part of ggplot2

fig<-plot_ly(mpg,x=~cty, y=~hwy, 
             color=~drv,
             frame =~class,
             type="scatter",
             mode="markers")

fig
#> Warning in p$x$data[firstFrame] <- p$x$frames[[1]]$data: number of items to
#> replace is not a multiple of replacement length

Created on 2023-06-15 with reprex v2.0.2

But it does seem to take a few attempts before it clicks.

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.