我要创建这样一个下面选择选项,闪亮 - “选项”中的所有子列表都必须命名?
<select id="species">
<option value="1">A</option>
<option value="2">B</option>
<option value="3">C</option>
</select>
所以我用数据帧来创建一个存储数据的表,
# Create the species table for select input.
title <- c('A', 'B', 'C')
code <- c('1', '2', '3')
species <- data.frame(title, code)
# Set choices of title and code for select input.
choicesSpecies <- setNames(species$code, species$title)
闪亮的ui.R,
selectInput(inputId = "species",
label = "Species:",
choices = choicesSpecies),
我得到这个错误,
Error in (function (choice, name) :
All sub-lists in "choices" must be named.
这是什么意思?我如何解决它以获得我需要的结果?
你可以尝试使用'choices = species $ code',然后使用'switch'语句来获得等价的代码吗? – tospig
当你用这种方式设置名称时(当我使用这种方法时我从来没有得到错误),错误是否也会发生:choicesSpecies < - species $ code;名称(choicesSpecies)< - species $ title – rdatasculptor
谢谢你们。但没有任何建议工作恐怕... – laukok