我无法将用于列标题的数字选择从1到50链接到反应数据集的UI selectInput()。以下代码的每个其他部分都可以正常工作,除了这个,
TEMP3 [,输入$为col_num] LT; -as.factor(TEMP3 [,输入$为col_num])
它表示[.data.frame中的错误:选择了未定义的列。以下是代码,
both_na<-reactive({
source("D:/Documents/R_Projects/Data_Camp_Tutorials/
ML_Tree_App/functions.R")
file1<-input$file
temp3<-read.csv(file=file1$datapath, sep=input$sep,
header = input$header, stringsAsFactors =
input$stringAsFactors)
# create logical set for numeric columns
temp3[,input$col_num]<-as.factor(temp3[,input$col_num])
temp3[,sapply(temp3,is.numeric)]<-
lapply(temp3[,sapply(temp3,is.numeric)], function(x) replace(x, is.na(x),
mean(x[!is.na(x)])))
temp3[,!sapply(temp3,is.numeric)]<-
lapply(temp3[,!sapply(temp3,is.numeric)], function(x) replace(x,
is.na(x), Mode(x[!is.na(x)])))
temp3
})