Pablo Bernabeu Pablo Bernabeu - 24 days ago 8
R Question

Shiny: Unwanted space before italicized word

If you have some experience with the Shiny environment, I would like to ask your help with a little issue. It regards the italicization of text. I have a single italicized word within a normal paragraph, as below:

p(".....blabla (", em("italicized)"), "blabla")


The problem is a space that pops up just before the italicized word, as in: ".....blabla ( italicized)". Would you know how to cancel it?

The problem arises both locally as well as on my shinyapps.io webpage.

N.B. I already asked in the Shiny Google group but there were no answers.

Thank you so much

Further below, I attach an example of the ui.R for reproducibility, to comply with a request. The error is in the third line from the end.

As a disclaimer, though, please note that if remotely this example should have any errors with parentheses or such, the unwanted space I get is with all certainty not due to any of those. The code is altogether smooth besides the unwanted space. I humbly believe this example is not very necessary. The error is only about the unwanted space I get from:

p(".....blabla (", em("italicized)"), "blabla")





library(shiny)
library(ggplot2)
library(leaflet)
library(RCurl)
library(scales)
library(rsconnect)

shinyUI(fluidPage(titlePanel(h3('title',
align = 'center', style = 'color:marengo')),

sidebarLayout(
sidebarPanel(width = 2,
h5(strong('blabla'),
align = 'center'),
selectInput('var1', label = 'blabla',
choices = list('blabla', 'blabla', 'blabla'),
selected = 'blabla'),

selectInput('var2', label = 'blabla',
choices = list('blabla','blabla'),
selected = 'blabla' ),
helpText('blabla')),

mainPanel(
br(),
plotOutput('plot'),
p(".....blabla (", em("italicized)"), "blabla"),
br(),
height = 8, width = 10))))

Answer

The function p() might have unwanted side effects. Instead try:

HTML(paste0(".....blabla (", em("italicized)"), "blabla"))