我正在构建一个小UI,用户将进入splitLayout文本行,构建一个语句(此问题不需要)来解决难题.
但是,如果用户决定他/她需要额外的行或更少的行来解决难题,我想添加或删除新的输入行以不删除剩余的输入行.
我怎样才能最好地达到我想要的结果:
请在下面找到我修剪过的代码.感谢您的输入.
library(shiny)
# Define UI
ui <- fluidPage(
# Application title
titlePanel("Identify A, B and C"),
sidebarLayout(
sidebarPanel(width = 5,
helpText("Present a statement and receive a response: 1 is a Knight who always tells the truth, 2 is a Knave who always lies, and 3 is a Normal who can do either."),
# Number of Questions
numericInput(inputId = "Questions", label = "Number of Questions",
value = 1, min = 1, max = …Run Code Online (Sandbox Code Playgroud) 我正在寻找一个功能,用户可以输入自己的模型选择功能作为要使用的输入.我无法找到答案,因为我不断获得有关如何创建简单R函数的搜索结果,而不像应用系列那样输入.
这是一个类似于我正在寻找但不完全的例子:
simple<- function(mod, FUN){
switch(FUN,
AIC = AIC(mod),
BIC = BIC(mod))
}
simple(lm(rnorm(100) ~ rnorm(100,4)), "AIC")
Run Code Online (Sandbox Code Playgroud)
上面的代码运行但我必须计划所有可能的功能并在switch中写入它们.我也被迫写"AIC"而不是简单的AIC.
有关如何创建我正在寻找的功能的任何想法?如果您需要其他信息,请与我们联系.
我试图获取一个which(..., arr.ind = TRUE)函数的结果,并删除不是第一个彼此"连接"的行.
例子:
#example 1 example 2 example 3
row col row col row col
1 4 2 3 1 3
2 4 2 4 2 5
4 5 3 5 3 5
3 6 2 7 4 6
4 6 3 7 5 6
3 7 4 7 6 8
4 7 5 7 9 10
# should become (trimmed.mtx)
row col row col row col
1 4 2 3 1 3
4 5 3 …Run Code Online (Sandbox Code Playgroud)