new line on comma - code styling with R styler

32 Views Asked by At

Given this messy code:

code = "p <- plot_ly(df, x = ~`Month-year`, y = ~Portafolio, type = 'scatter', mode = 'lines+markers', name = 'Portafolio',marker=list(color='#2ca02c',line = list(color = '#2ca02c')),line=list(color='#2ca02c')) %>%
add_trace(x = ~`Month-year`, y = ~Clients, type = 'scatter', mode = 'lines+markers', yaxis = 'y2', name = 'Clients',marker=list(color='#ff7f0e'),line=list(color='#ff7f0e')) %>%
  layout(yaxis2 = list(title='Clients', side = 'right', overlaying = 'y', side ='right', automargin=T, showgrid=FALSE,rangemode='tozero'), yaxis=list(showgrid=FALSE,rangemode='tozero'), xaxis=list(showticklabels=TRUE,visible=TRUE),title = '0015',legend = list(orientation = 'h',x = 0, y = 1), shapes = list(list(type = 'rect', text = 'Festival', fillcolor = 'green', line = list(color = 'green'),opacity = 0.2, y0 = 0.0, y1 = max(df$Clients), x0 = '2022-06-01', x1 = '2022-07-01',plot_bgcolor = '#e5ecf6'))) %>%
  add_text(showlegend = FALSE,x = '2022-06-15', y = max(df$Clients)+max(df$Clients)*0.03, text = 'Festival',textfont = list(color = 'green', size = 15))"

How do I style it in order to have new lines after comma? Aka:

plot_ly(
  data = df,
  x = ~`Month-year`,
  y = ~Portafolio,
...

Somethink like this does not do the job:

styler::style_text(code, strict = TRUE) 
0

There are 0 best solutions below