在我的闪亮应用程序中,我想添加一个选项,让用户tab通过点击infoBox(或我想要的任何其他对象)跳转到应用程序中的特定元素(表格,情节,任何具有id的内容),当前或不同).
我的解决方案是围绕infoBox与div并添加href=#id_of_element属性.不幸的是,这个解决方案只适用tabs于额外的"data-toggle" = "tab"属性(它也不会改变打开tab的active),但这不是我想要的.
我的问题是:如何添加上述选项以及为什么此解决方案不起作用?这是我想要做的一个小例子:
UI
library(shiny)
library(shinydashboard)
shinyUI(
dashboardPage(
skin = "blue",
dashboardHeader(title = "Example"),
dashboardSidebar(
sidebarMenu(id = "sidebarmenu",
menuItem("Tab1", icon = icon("line-chart"),
menuSubItem("SubTab1", tabName = "sub1", icon = icon("bar-chart")),
menuSubItem("SubTab2", tabName = "sub2", icon = icon("database"))),
menuItem("Tab2", tabName = "tab2", icon = icon("users"))
)
),
dashboardBody(
tabItems(
tabItem(tabName = "sub1",
tags$div(href="#s2t2",
infoBox(value = "Go to table 2 in SubTab2 (not …Run Code Online (Sandbox Code Playgroud) 我有一个Shiny正在显示一些图像的应用程序。对于选定的图像,我有pan和zoom(使用svgPanZoom包装)和亮度更改(使用sliderInput)。同样在按钮上单击我将移至下一张图像。不幸的是,每当我单击按钮或更改滑块上的值zoom并pan重置时(这不足为奇)。请参见下面的示例:
有什么方法可以使pan和zoom值保持inputs不变?我在考虑一个javascript代码,我将保存这些值并使用发送到新的输入Shiny.setInputValue,但是现在我什pan至无法获得当前和zoom。
这是我尝试运行的示例应用程序代码和JS:
# global.R
library(tidyverse)
library(shiny.semantic)
library(semantic.dashboard)
library(svgPanZoom)
library(SVGAnnotation)
# Some image data
imgs <- 1:2 %>% map(~ array(runif(1080 * 680 * 3), dim = c(1080, 680, 3)))
# Zoom script
zoom_script <- tags$script(HTML(
'window.onload = function() {
var rtg_plot = document.getElementById("picture");
var btn_next = document.getElementById("next_pic");
btn_next.addEventListener("click", printZoom, false);
function printZoom() { …Run Code Online (Sandbox Code Playgroud) 我试图从dplyr帮助中运行简单的示例,但最近我得到了这个奇怪的错误:
> library(tidyverse)
> dplyr::rename(iris, petal_length = Petal.Length)
ERRROR: `petal_length` = Petal.Length must be a symbol or a string, not formula
Run Code Online (Sandbox Code Playgroud)
谁能告诉我发生了什么事?
> traceback()
11: stop(cnd)
10: .abort(text)
9: glubort(fmt_named_calls(named_calls), ..., .envir = .envir)
8: bad_named_calls(named_call, "must be a symbol or a string, not {actual_type}")
7: (function (expr, name)
{
switch_type(expr, string = , symbol = return(as_string(expr)),
language = if (is_data_pronoun(expr)) {
args <- node_cdr(expr)
return(switch_rename(node_cadr(args)))
}
else {
abort("Expressions are currently not supported in `rename()`")
})
actual_type …Run Code Online (Sandbox Code Playgroud) 我有一个fluidRow三列包含一些小部件.是否可以更改中间列的颜色(或此列中的所有小部件)?
例如:白色柱 - 灰色柱 - 白色柱
我的数据中有一些不平衡的数据LabeledPoint.我想做的是选择所有正面和n次数更多负面(随机).例如,如果我有100正面和30000负面,我想LabeledPoint用所有100正面和300负面创建新的(n=3).
在实际情况中,我并没有在开始时有多少积极和消极.
我的h2o.automl()例子来自:http://h2o-release.s3.amazonaws.com/h2o/master/3888/docs-website/h2o-docs/automl.html.一切都很好,除了NaN价值观leaderboard.预测也很好.这是一个错误还是我做错了什么?
library(h2o)
localH2O <- h2o.init(ip = "localhost",
port = 54321,
nthreads = -1,
min_mem_size = "20g")
train <- h2o.importFile("https://s3.amazonaws.com/erin-data/higgs/higgs_train_10k.csv")
test <- h2o.importFile("https://s3.amazonaws.com/erin-data/higgs/higgs_test_5k.csv")
y <- "response"
x <- setdiff(names(train), y)
train[,y] <- as.factor(train[,y])
test[,y] <- as.factor(test[,y])
aml <- h2o.automl(x = x, y = y,
training_frame = train,
leaderboard_frame = test,
max_runtime_secs = 30)
lb <- aml@leaderboard
lb
model_id auc logloss
1 StackedEnsemble_0_AutoML_20170908_094736 NaN NaN
2 StackedEnsemble_0_AutoML_20170908_094407 NaN NaN
3 GBM_grid_0_AutoML_20170908_094736_model_1 NaN …Run Code Online (Sandbox Code Playgroud) 我正在运行Bernoulli Naive Bayes使用代码:
val splits = MyData.randomSplit(Array(0.75, 0.25), seed = 2L)
val training = splits(0).cache()
val test = splits(1)
val model = NaiveBayes.train(training, lambda = 3.0, modelType = "bernoulli")
Run Code Online (Sandbox Code Playgroud)
我的问题是我如何才能获得0级(或1级)成员资格的概率并计算AUC.我想得到类似的结果LogisticRegressionWithSGD或SVMWithSGD我使用此代码的地方:
val numIterations = 100
val model = SVMWithSGD.train(training, numIterations)
model.clearThreshold()
// Compute raw scores on the test set.
val labelAndPreds = test.map { point =>
val prediction = model.predict(point.features)
(prediction, point.label)
}
// Get evaluation metrics.
val metrics = new BinaryClassificationMetrics(labelAndPreds)
val auROC = …Run Code Online (Sandbox Code Playgroud) apache-spark pyspark naivebayes apache-spark-ml apache-spark-mllib
r ×6
shiny ×3
apache-spark ×2
dplyr ×1
ggplot2 ×1
h2o ×1
href ×1
html ×1
javascript ×1
naivebayes ×1
plot ×1
pyspark ×1
regression ×1
rename ×1
sampling ×1
scala ×1
svgpanzoom ×1