# knitR error with plotly layout

**URL:** <https://community.plotly.com/t/knitr-error-with-plotly-layout/2024>\
**Category:** Plotly R\
**Created:** [September 1, 2016, 6:56am UTC](https://community.plotly.com/t/knitr-error-with-plotly-layout/2024 "2016-09-01T06:56:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![slackoverflow](https://avatars.discourse-cdn.com/v4/letter/s/8dc957/32.png) [@slackoverflow](https://community.plotly.com/u/slackoverflow)\
**Post date:** [September 1, 2016, 6:56am UTC](https://community.plotly.com/t/knitr-error-with-plotly-layout/2024/1 "2016-09-01T06:56:32Z")

</div>

I’m not able to fix this problem. Whenever I try to upload my knitR markdown I get the following error:

 ![](https://us1.discourse-cdn.com/flex024/uploads/plot/original/1X/331eda177feab403088e58a23dddb9ab02f0f7d7.png)

This is my code:

```
df$hover <- with(df, paste(Country,'<br>', "New Sessions (%)", `New Sessions`, '<br>', "New Users", `New Users`, '<br>', "Bounce Rate (%)", `Bounce Rate`, '<br>', "Avg. Session Duration (sec)", `Avg. Session Duration`))

# give state boundaries a white border
l <- list(color = toRGB("grey"), width = 0.5)
# specify some map projection/options
g <- list(
  showframe = FALSE,
  showcoastlines = FALSE,
  projection = list(type = 'Mercator')
)

 plot_ly(df, z = Sessions, text = hover, locations = country.code, type = 'choropleth',
     color = Sessions, colors = 'Blues', marker = list(line = l),
     colorbar = list(title = 'Sessions')) %>%
     layout(title = '# of Sessions Aug 1 - Aug 30<br>(Hover for breakdown)', geo = g)

```

And here what the plot looks like: [https://plot.ly/~slackoverflow/53/of-sessions-aug-1-aug-30-hover-for-breakdown/](https://plot.ly/~slackoverflow/53/of-sessions-aug-1-aug-30-hover-for-breakdown/)

When I remove the `layout` part, everything is alright. In R Studio I can run the Code with layout without any probs. Just when trying to format it to HTML it doesn’t work. Been googling this for a while, and couldn’t find any solution. I’d really appreciate any help on this.
