我想让用户输入一个文件(.csv),并且从该文件中,将使用.csv的列名填充两个selectizeInput。用户会询问用户上传文件中的哪些列是y变量,哪些列是x变量。这个,我能做到的。
我不能做的是以下内容:我想从y变量中选择从x变量下拉菜单中的x变量选项中消失。
此外,我已使用answer to this question尝试提供帮助,但他们没有使用fileInput中的值。因此,我无法获得下面的代码。感谢您提供任何建议/帮助。
ui<- fluidPage(
titlePanel("Test"),
sidebarPanel(
fileInput(inputId = "file1", label = "Upload File"),
selectizeInput(
"sampleyvars", "Y-vars", choices = NULL, multiple = FALSE
),
selectizeInput(
"samplevars", "X-vars", choices = NULL, multiple = TRUE
)
),
mainPanel(h3("Nothing special")
)
)
server<- function(input, output, session) {
observe({
file1 <- input$file1
if(is.null(file1)){return()}
dataSet <- read.csv(file=file1$datapath)
vals1<-input$sampleyvars
vals2<-input$samplevars
updateSelectizeInput(session, "sampleyvars",
choices = colnames(dataSet)[! vals1 %in% vals2])
updateSelectizeInput(session, "samplexvars",
choices =colnames(dataSet)[! vals2 %in% vals1])
})
}
shinyApp(ui = ui,server = server)
答案 0 :(得分:1)
您在domReady(function(event) {
var menuButton = document.getElementById('nav-button');
var menuButtonNav = document.getElementById('nav-main');
var menuPageWrap = document.getElementById('nav-page-wrap');
var menuEls = [
menuPageWrap
];
addEvent(menuButton, 'click', function(){
var i;
for ( i = 0; i <= menuEls.length; i ++ ) {
menuEls[i].classList.toggle('is--open')
}
})
/*
addEvent(menuButton, 'click', function(){
menuButtonNav.classList.toggle('is--open');
menuPageWrap.classList.toggle('is--open');
menuButton.classList.toggle('is--open');
});
*/
console.log(menuEls[0])
console.log(menuEls[0].classList)
});
函数中使用的X变量小部件Unhandled event loop exception
ObjectNotModifiableException: Attempt to modify read-only object: //WebDynpro/Controller:com.pwc.bc.registration.wd.parnr.approval.comp.PartnerNumberApprovalCompInterface!
at com.sap.ide.metamodel.core.DevelopmentObjectProxy._prepareForModify(DevelopmentObjectProxy.java:465)
at com.sap.ide.metamodel.webdynpro.implementation.AppClassProxy.setCodeBody(AppClassProxy.java:668)
at com.sap.ide.webdynpro.componentmigration.internal.actions.DeleteInterfaceControllerImplementationCodingAction.run(DeleteInterfaceControllerImplementationCodingAction.java:23)
at org.eclipse.ui.internal.cheatsheets.ActionRunner.runAction(ActionRunner.java:86)
at org.eclipse.ui.internal.cheatsheets.data.Action.execute(Action.java:100)
at org.eclipse.ui.internal.cheatsheets.views.CoreItem.runExecutable(CoreItem.java:497)
at org.eclipse.ui.internal.cheatsheets.views.CoreItem.runExecutable(CoreItem.java:492)
at org.eclipse.ui.internal.cheatsheets.views.CheatSheetViewer.runPerformExecutable(CheatSheetViewer.java:1044)
at org.eclipse.ui.internal.cheatsheets.views.CoreItem$1.linkActivated(CoreItem.java:89)
at org.eclipse.ui.forms.widgets.AbstractHyperlink.handleActivate(AbstractHyperlink.java:233)
at org.eclipse.ui.forms.widgets.ImageHyperlink.handleActivate(ImageHyperlink.java:199)
at org.eclipse.ui.forms.widgets.AbstractHyperlink.handleMouseUp(AbstractHyperlink.java:327)
at org.eclipse.ui.forms.widgets.AbstractHyperlink.access$2(AbstractHyperlink.java:311)
at org.eclipse.ui.forms.widgets.AbstractHyperlink$4.handleEvent(AbstractHyperlink.java:125)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3910)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3503)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2405)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2369)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2221)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:493)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
错误ID
而不是samplevars
。我将其更改为后一个ID,并稍微调整了您的代码以获得所需的效果。
完整示例:
samplexvars