Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将选定的colname获取为R/S中的字符_R_Shiny_Data Science - Fatal编程技术网

将选定的colname获取为R/S中的字符

将选定的colname获取为R/S中的字符,r,shiny,data-science,R,Shiny,Data Science,我正在尝试根据selectInput中的选定列对数据进行子集划分。我试过: as.character(input$LabelBubble) 但这似乎无法提取列文本。代码的其余部分,我选择以下列: output$LabelBubble = renderUI(if(input$PlotType=="Dynamic Bubble Scatter"){ mtext <- sapply(loadfile1(), is.factor) mcols<-as.list(colnames(loa

我正在尝试根据selectInput中的选定列对数据进行子集划分。我试过:

as.character(input$LabelBubble)
但这似乎无法提取列文本。代码的其余部分,我选择以下列:

output$LabelBubble = renderUI(if(input$PlotType=="Dynamic Bubble Scatter"){
 mtext <- sapply(loadfile1(), is.factor)
 mcols<-as.list(colnames(loadfile1()[,mtext]))
 selectInput(
  "LabellBubble", 
  label = "Select factor variable",
  "",selectize=TRUE,multiple=FALSE,choices=mcols
 )
})
输出$labelubble=renderUI(如果(输入$PlotType==“动态气泡散布”){

mtext我认为您的问题是当
mtext
中只有一列时,
loadfile1()[,mtext]
返回一个向量而不是一个data.frame。如果您使用
dplyr
可以执行类似的操作,从而获得更好的结果

mcols<-as.list(colnames(select(iris,one_of(names(mtext)[mtext]))))

mcolsThanks很多。这是我最初没有想到的解决方案。但是如何从selectInput中提取动态子集的选定列的名称呢?