我正在尝试使用 grepl 从数据框中提取某些记录。
这是基于两列结果和名称之间的比较。这个变量是这样构建的,但是对于同一个单词,我有多个数字(超过 30 个),所以当我使用 grepl 表达式来获取例如 Word1 时,我也会得到我想要避免的结果,如 Word12。
有想法该怎么解决这个吗?
Names <- c("Word1")
colnames(Names) <- name
Results <- c("Word1", "Word11", "Word12", "Word15")
Records <- c("ThisIsTheResultIWant", "notThis", "notThis", "notThis")
Relationships <- data.frame(Results, Records)
Relationships <- subset(Relationships, grepl(paste(Names$name, collapse = "|"), Relationships$Results))
Run Code Online (Sandbox Code Playgroud)
这不起作用,如果我使用fixed = TRUE它根本不返回任何结果(这很奇怪)。我也尝试将名称部分与这样的其他数字连接,但没有成功:
Relationships <- subset(Relationships, grepl(paste(paste(Names$name, '3', sep = ""), collapse = "|"), Relationships$Results))
Run Code Online (Sandbox Code Playgroud)
由于我正在连接,因此我不太确定如何使用 \b 来强制执行完全匹配。
有什么建议?
We need to create a hierarchical drop-down list in R shiny. The list will have at least 3 levels. Could you please help me in identifying the correct library for this? Please refer the below pic for your reference.Currently we are using the below code.But we are getting incorrect columns in the drop-down.
ui.R
library(shiny)
library(shinydashboard)
library(shinyTree)
shinyUI(
shiny::fluidPage(
h3('Countries '),
shinyTree("tree", checkbox = TRUE),
verbatimTextOutput("x")
)
)
server.R
library(shiny)
library(shinydashboard)
library(shinyTree)
library(treemap)
data(GNI2014)
head(GNI2014)
GNI2014$pathString <- paste("world",
GNI2014$continent,
GNI2014$country, …Run Code Online (Sandbox Code Playgroud)