在 shinydashboard::box 中格式化帮助文本
format helpText in shinydashboard::box
我的 shiny 应用程序的 shinydashboard 框中有一个 helpText 小部件。
shinydashboard::box() 之外的帮助文本可以轻松格式化,但是,在 box() 中,新行以及其他 HTML 元素不受尊重。
请在下面找到我的代码和我目前正在获取的图像。
validation_rules_text_cas<-helpText('Please enter one string per line.', # ----
"A CAS Registry Number includes up to 10 digits which are separated in 3 hyphens.",
'- The first part of the number, starting from the left, has 2 to 7 digits',
'- The second part has 2 digits',
'- The final part consists of a single check digit.')
validation_rules_text_inchikey<-helpText('Please enter one string per line.',
"International Chemical Identifier KEY validation rules. InChIKey consists of several distinct components:",
"- 14 characters resulting from a hash of the connectivity information of the InChI,encodes molecular skeleton (connectivity),",
"- followed by a hyphen,",
"- followed by 8 characters resulting from a hash of the remaining layers of the InChI,",
"- Encodes proton positions (tautomers), stereochemistry, isotopomers, reconnected layer,",
"- followed by a single character indicating the kind of InChIKey,",
"- followed by a single character indicating the version of InChI used,",
"- another hyphen,",
"- followed by single character indicating protonation.(Source: Wikipedia).",
" AAAAAAAAAAAAAA-BBBBBBBBCD-E")
tabPanel("Batch Search", #----
fluidRow(column(5),
column(7,# helpText----
box(title=' CAS Validation Rules',width=12,
collapsible = TRUE,
collapsed=TRUE,
status = 'primary',
validation_rules_text_cas
),
box(title='Inchikey Validation Rules',width=12,
collapsible = TRUE,
collapsed=TRUE,
status = 'primary',
validation_rules_text_inchikey
),
box(title='SMILES Validation Rules',width=12,
collapsible = TRUE,
collapsed=TRUE,
status = 'primary',
validation_rules_text_smiles
),
box(title='Validation Rules - OTHER',width=12,
collapsible = TRUE,
collapsed=TRUE,
status = 'primary',
validation_rules_text_other
))
))
如何添加换行符 (tags$br()) 或新行 (tags$hr())?谢谢
在renderText
中使用\n
即可。试试这个
ui <- fluidPage(
tags$head(tags$style("#inchikey{color: blue;
font-size: 16px;
line-height: 0.6;
}"
)),
tabPanel("Batch Search", #----
fluidRow(column(5),
column(7,# helpText----
box(title=' CAS Validation Rules',width=12,
collapsible = TRUE,
collapsed=TRUE,
status = 'primary',
validation_rules_text_cas
),
box(title='Validation Rules - OTHER',width=12,
collapsible = TRUE,
collapsed=TRUE,
status = 'primary',
verbatimTextOutput("inchikey")
#validation_rules_text_inchikey
)
)
))
)
server <- function(input, output, session) {
output$inchikey <- renderText({
paste("Please enter one string per line., \n
International Chemical Identifier KEY validation rules. InChIKey consists of several distinct components: \n
- 14 characters resulting from a hash of the connectivity information of the InChI,encodes molecular skeleton (connectivity), \n
- followed by a hyphen, \n
- followed by 8 characters resulting from a hash of the remaining layers of the InChI, \n
- Encodes proton positions (tautomers), stereochemistry, isotopomers, reconnected layer, \n
- followed by a single character indicating the kind of InChIKey, \n
- followed by a single character indicating the version of InChI used, \n
- another hyphen, \n
- followed by single character indicating protonation.(Source: Wikipedia). \n
AAAAAAAAAAAAAA-BBBBBBBBCD-E", sep="\n")
})
}
shinyApp(ui = ui, server = server)
基于此,您可以在服务器函数中使用renderUI
,在ui中使用htmlOutput
。例如:
output$validrules <- uiOutput({
HTML(paste(
p('Please enter one string per line.'),
p("A CAS Registry Number includes up to 10 digits which are separated in 3 hyphens."),
p('- The first part of the number, starting from the left, has 2 to 7 digits'),
p('- The second part has 2 digits'),
p('- The final part consists of a single check digit.')
))
})
然后:
box(title=' CAS Validation Rules',width=12,
collapsible = TRUE,
collapsed=TRUE,
status = 'primary',
htmlOutput("validrules")
)
我的 shiny 应用程序的 shinydashboard 框中有一个 helpText 小部件。 shinydashboard::box() 之外的帮助文本可以轻松格式化,但是,在 box() 中,新行以及其他 HTML 元素不受尊重。 请在下面找到我的代码和我目前正在获取的图像。
validation_rules_text_cas<-helpText('Please enter one string per line.', # ----
"A CAS Registry Number includes up to 10 digits which are separated in 3 hyphens.",
'- The first part of the number, starting from the left, has 2 to 7 digits',
'- The second part has 2 digits',
'- The final part consists of a single check digit.')
validation_rules_text_inchikey<-helpText('Please enter one string per line.',
"International Chemical Identifier KEY validation rules. InChIKey consists of several distinct components:",
"- 14 characters resulting from a hash of the connectivity information of the InChI,encodes molecular skeleton (connectivity),",
"- followed by a hyphen,",
"- followed by 8 characters resulting from a hash of the remaining layers of the InChI,",
"- Encodes proton positions (tautomers), stereochemistry, isotopomers, reconnected layer,",
"- followed by a single character indicating the kind of InChIKey,",
"- followed by a single character indicating the version of InChI used,",
"- another hyphen,",
"- followed by single character indicating protonation.(Source: Wikipedia).",
" AAAAAAAAAAAAAA-BBBBBBBBCD-E")
tabPanel("Batch Search", #----
fluidRow(column(5),
column(7,# helpText----
box(title=' CAS Validation Rules',width=12,
collapsible = TRUE,
collapsed=TRUE,
status = 'primary',
validation_rules_text_cas
),
box(title='Inchikey Validation Rules',width=12,
collapsible = TRUE,
collapsed=TRUE,
status = 'primary',
validation_rules_text_inchikey
),
box(title='SMILES Validation Rules',width=12,
collapsible = TRUE,
collapsed=TRUE,
status = 'primary',
validation_rules_text_smiles
),
box(title='Validation Rules - OTHER',width=12,
collapsible = TRUE,
collapsed=TRUE,
status = 'primary',
validation_rules_text_other
))
))
如何添加换行符 (tags$br()) 或新行 (tags$hr())?谢谢
在renderText
中使用\n
即可。试试这个
ui <- fluidPage(
tags$head(tags$style("#inchikey{color: blue;
font-size: 16px;
line-height: 0.6;
}"
)),
tabPanel("Batch Search", #----
fluidRow(column(5),
column(7,# helpText----
box(title=' CAS Validation Rules',width=12,
collapsible = TRUE,
collapsed=TRUE,
status = 'primary',
validation_rules_text_cas
),
box(title='Validation Rules - OTHER',width=12,
collapsible = TRUE,
collapsed=TRUE,
status = 'primary',
verbatimTextOutput("inchikey")
#validation_rules_text_inchikey
)
)
))
)
server <- function(input, output, session) {
output$inchikey <- renderText({
paste("Please enter one string per line., \n
International Chemical Identifier KEY validation rules. InChIKey consists of several distinct components: \n
- 14 characters resulting from a hash of the connectivity information of the InChI,encodes molecular skeleton (connectivity), \n
- followed by a hyphen, \n
- followed by 8 characters resulting from a hash of the remaining layers of the InChI, \n
- Encodes proton positions (tautomers), stereochemistry, isotopomers, reconnected layer, \n
- followed by a single character indicating the kind of InChIKey, \n
- followed by a single character indicating the version of InChI used, \n
- another hyphen, \n
- followed by single character indicating protonation.(Source: Wikipedia). \n
AAAAAAAAAAAAAA-BBBBBBBBCD-E", sep="\n")
})
}
shinyApp(ui = ui, server = server)
基于此renderUI
,在ui中使用htmlOutput
。例如:
output$validrules <- uiOutput({
HTML(paste(
p('Please enter one string per line.'),
p("A CAS Registry Number includes up to 10 digits which are separated in 3 hyphens."),
p('- The first part of the number, starting from the left, has 2 to 7 digits'),
p('- The second part has 2 digits'),
p('- The final part consists of a single check digit.')
))
})
然后:
box(title=' CAS Validation Rules',width=12,
collapsible = TRUE,
collapsed=TRUE,
status = 'primary',
htmlOutput("validrules")
)