在语法定义中表示Sublime Text正则表达式中的“小于”符号(Represent “less-than” symbol in Sublime Text regex in syntax definition)
我正在使用一个古老的前XML标记,它使用“$ = x”形式的代码,其中x可以是字母字符或键盘上的符号,例如
;
(分号),? (问号)或<
(右左角括号,又大于小于)。 [编辑后的注意事项:原始措辞中出现的混淆问题是问题的核心所在。 请参阅我对已接受答案的评论。 RS]所以我在我的User文件夹中修改了XML.tmLanguage语法定义文件的副本,以识别这些代码所代表的11个不同的类别,因此我可以在大文本文件(也包含XML标记)中轻松看到它们我是与...合作。
对于所有符号,除了
<
我能够通过在其前面加上反斜杠来转义符号。 但是在ST2使用的Boost正则表达式引擎中,\<
是表示您只想在单词的开头匹配的方式。 因此,我无法正确识别和突出显示此代码。在这种情况下,我到处寻找如何逃避
<
符号。 我试过用0,1,2,3和4反斜杠前面的; 我也尝试使用十六进制转义码\x{3009}
。 [注意:这是大于而不是小于的代码。]一切都是徒劳。 (一些替代方案没有生成错误消息,但也没有突出显示代码。)
因为我正在处理的代码需要以不同的颜色着色,所以我不能使用通用符号代替
<
,我也不能指定它。 我怎么得到这个?I'm working with an ancient pre-XML markup that uses codes of the form "$=x", where x may be an alphabetic character or a symbol on the keyboard, such as
;
(semicolon),?
(question mark), or<
(rightleft angle bracket, akagreater-thanless-than). [Note after editing: the confusion manifested in the question as originally phrased goes to the heart of the problem. See my comment to the accepted answer. RS]So I've modified a copy of XML.tmLanguage syntax definition file in my User folder to identify the eleven different categories that these codes represent, so I can easily see them in the large text files (which also contain XML markup) I'm working with.
For all the symbols except
<
I'm able to escape the symbol by preceding it with a backslash. But in the Boost regex engine that ST2 uses,\<
is how you indicate that you want to match only at the start of a word. Consequently I've been unable to get this code to be properly recognized and highlighted.I've looked everywhere for how to escape the
<
symbol in this circumstance. I've tried preceding it with 0, 1, 2, 3 and 4 back-slashes; and I also tried using the hexadecimal escape code\x{3009}
. [Note: this is the code for greater-than instead of less-than.]All in vain. (A few alternatives didn't generate an error message but also didn't highlight the code.)
Because the codes I'm working with need to be colored differently, I can't use a generic symbol in lieu of
<
, and I can't specify it either. How do I get this?
原文:https://stackoverflow.com/questions/19571749
最满意答案
我已经编辑了代码现在正在工作。 你应该把两个输入放在两个不同的观察中。
这是服务器。 R:
server <- function(input, output, session){ fund_group <- reactive({ # this is the list of fund group including fund name # for example, list("domestic" = c("a","b", "c"), "global" = c( "aa", "bb", "cc")) # list name and fund name in the list are changable }) observe({ group_name <- reactive({ names(fund_group()) }) updateSelectInput( session, "select_group", choices = group_name() ) }) observe({ fund_list <- reactive({ fund_group()[[input$select_group]] }) updateCheckboxGroupInput( session, "fund_in_group", choices = fund_list(), selected = fund_list()) }) }
这是ui.R:
ui <- navbarPage( "narvarTitle", tabPanel( "tab panel", fluidRow( column( 3, wellPanel( textOutput( "fixed_anual_date" ), br(), br(), selectInput( "select_group", label = "Select group", choices = "" ), br(), checkboxGroupInput( "fund_in_group", label = "Select funds :", choices = "" ), br() ) ) ) ) )
[编辑]:
根据您的最新更新,我修改了服务器代码,以便在
dataset
更改时更新checkboxGrouptInput
并为已检查的列呈现表。shinyServer( function(input, output, session) { dataset_list <- list( "rock" = rock, "pressure" = pressure, "cars" = cars ) observeEvent( input$n_select_input, { selected_dataset <- reactive({ selected_list <- list() for( i in 1:input$n_select_input ){ selected_list[[i]] <- dataset_list[[i]] } names(selected_list) <- names( dataset_list )[1:input$n_select_input] selected_list }) colname_indata_list <- reactive({ colname.indata.list <- list() for( set in names( selected_dataset() ) ){ colname.indata.list[[set]] <- colnames( selected_dataset()[[set]] ) } colname.indata.list }) choice_cand <- reactive({ names(selected_dataset()) }) updateSelectInput( session, "dataset", choices = as.character( choice_cand() ) ) ######################################Start: Modified############################# observe({ input$dataset ##Added so that this observe is called when the input$dataset changes choices_cand <- reactive({ colname_indata_list()[[input$dataset]] }) updateCheckboxGroupInput( session, "column", choices = as.character( choices_cand()) , selected = as.character( choices_cand()) ) }) }) ######################################End: Modified############################# datasetInput <- reactive({ switch(input$dataset, "rock" = rock, "pressure" = pressure, "cars" = cars) }) output$table <- renderTable({ datasetInput()[,input$column]##only selected columns are displayed }) } )
希望这可以帮助!
I have edited the code an its working now. You should put the two input in two different observe.
Here is the server. R:
server <- function(input, output, session){ fund_group <- reactive({ # this is the list of fund group including fund name # for example, list("domestic" = c("a","b", "c"), "global" = c( "aa", "bb", "cc")) # list name and fund name in the list are changable }) observe({ group_name <- reactive({ names(fund_group()) }) updateSelectInput( session, "select_group", choices = group_name() ) }) observe({ fund_list <- reactive({ fund_group()[[input$select_group]] }) updateCheckboxGroupInput( session, "fund_in_group", choices = fund_list(), selected = fund_list()) }) }
Here is the ui.R:
ui <- navbarPage( "narvarTitle", tabPanel( "tab panel", fluidRow( column( 3, wellPanel( textOutput( "fixed_anual_date" ), br(), br(), selectInput( "select_group", label = "Select group", choices = "" ), br(), checkboxGroupInput( "fund_in_group", label = "Select funds :", choices = "" ), br() ) ) ) ) )
[EDIT]:
As per your latest update I have modified the server code so that
checkboxGrouptInput
is updated asdataset
changes and also the table is rendered for the checked columns.shinyServer( function(input, output, session) { dataset_list <- list( "rock" = rock, "pressure" = pressure, "cars" = cars ) observeEvent( input$n_select_input, { selected_dataset <- reactive({ selected_list <- list() for( i in 1:input$n_select_input ){ selected_list[[i]] <- dataset_list[[i]] } names(selected_list) <- names( dataset_list )[1:input$n_select_input] selected_list }) colname_indata_list <- reactive({ colname.indata.list <- list() for( set in names( selected_dataset() ) ){ colname.indata.list[[set]] <- colnames( selected_dataset()[[set]] ) } colname.indata.list }) choice_cand <- reactive({ names(selected_dataset()) }) updateSelectInput( session, "dataset", choices = as.character( choice_cand() ) ) ######################################Start: Modified############################# observe({ input$dataset ##Added so that this observe is called when the input$dataset changes choices_cand <- reactive({ colname_indata_list()[[input$dataset]] }) updateCheckboxGroupInput( session, "column", choices = as.character( choices_cand()) , selected = as.character( choices_cand()) ) }) }) ######################################End: Modified############################# datasetInput <- reactive({ switch(input$dataset, "rock" = rock, "pressure" = pressure, "cars" = cars) }) output$table <- renderTable({ datasetInput()[,input$column]##only selected columns are displayed }) } )
Hope this helps!
相关问答
更多-
您可以在服务器内使用reactiveVal来保存“状态”(已更改或未更改)。 只要按下按钮或输入改变,只需确保状态得到更新。 library(shiny) library(shinydashboard) ui <- fluidPage( inputPanel( #arbritray inputs sliderInput("in1", label = "Input 1", value=1,min=0,max=5), sliderInput("in2", label = "Inpu ...
-
R Shiny:for循环输出可用于许多render *()函数(R Shiny: The for loop output available for many render*() functions)[2023-06-08]
将for循环解压缩为函数。 只要您没有在反应上下文之外调用函数( render* , reactive , observe ),您就可以在函数中使用无效值。 例: printTable <- function() { for (i in Table()$rn) { print (fun(Table()$a[i], Table()$b[i])) } } output$summary <- renderPrint({ printTable() }) output$data <- rend ... -
你有一些奇怪的事情发生,但最关注的事情似乎是你选择所选球员名称的ID的尝试。 假设csv injury作为数据框被读入,这应该起作用: library(shiny) injury <- read.csv("injury_app.csv", stringsAsFactors = FALSE) uniq_players <- sort(unique(injury$Player)) ui <- fluidPage( titlePanel("Title Goes Here"), sidebarLayou ...
-
这是一个似乎可行的解决方案。 我正在使用lapply来创建标签。 让我知道它是否适合您的需求。 library(shiny) ui <- pageWithSidebar( headerPanel("xxx"), sidebarPanel(), mainPanel( do.call(tabsetPanel, c(id='tab',lapply(1:5, function(i) { tabPanel( title=paste0('tab ', i), ...
-
发送tabe作为Shiny的输出不会在Shiny UI中呈现(Sending tabe as output from Shiny does not render in Shiny UI)[2022-06-18]
看看这是否有效: df2 <- reactive({ # Created DB Connection to get details input_var <- input$CPAN my_query <- paste("select CPAN,SCTP,MARKER,RESULT from CYTOKINE where CPAN= ", input_var) sqlQuery(dbconnect,my_query) cleandata <- na.omit(data) colname ... -
R闪亮渲染UI不起作用(R shiny render UI does not work)[2022-11-05]
如果x和y是字符串而lastgang是数据帧。 然后你的错误与使用shiny没有任何关系。 以下内容在R不起作用 > D <- data.frame(Col1=1:5, Col2=11:15) > a <- 'Col1' > b <- D$a > b NULL 这是因为$ R需要数据框的列名。 如果$之前的变量是数据框,那么如果列名不存在,则为NULL 。 您需要名为Col1的列 > D <- data.frame(Col1=1:5, Col2=11:15) > a <- 'Col1' > b <- D[ ... -
在与AndriyTkach讨论之后:我有一个工作计划: output$PowerAnalysisANOVA <- renderPlot({ allmean = c() for (i in 1:values$numGroups) eval (parse (text = paste0("allmean[", i, "] <- input$group_" ,i))) qplot(allmean) }) 我忘了制作一个反应变量: values <- reactiveValues() output$hmg ...
-
R Shiny:includeMarkdown无法呈现htmlwidgets(R Shiny: includeMarkdown cannot render htmlwidgets)[2022-02-06]
回答我自己的问题。 includeMarkdown中的代码不是由knitr执行的。 Answering my own question. The code in includeMarkdown is not be executed by knitr. -
如何在R中渲染不同的绘图输出类型取决于用户输入?(How to render different plot output types in R Shiny dependent of user input?)[2022-09-16]
类似的东西。 在server : output$plot <- renderPlot({ validate(need(input$pType=="A", message=FALSE)) hist(myData) }) output$dygraph <- renderDygraph({ validate(need(input$pType=="B", message=FALSE)) barplot(myData) }) 在ui : conditionalPanel('input.pType== ... -
我已经编辑了代码现在正在工作。 你应该把两个输入放在两个不同的观察中。 这是服务器。 R: server <- function(input, output, session){ fund_group <- reactive({ # this is the list of fund group including fund name # for example, list("domestic" = c("a","b", "c"), "global" = c( "aa", "bb", ...