将lapply()输出转换为R

时间:2018-06-26 11:31:17

标签: r dataframe lapply

当我尝试从Knn fold - cv获取准确的输出时,会得到零列表。

我不知道如何解决它,而实际上无法在数据框中获得准确的结果。

示例

anchoring <- read.delim("anchoring.csv", header = TRUE, sep=",", 
stringsAsFactors = FALSE)
ggg <- data.frame(anchoring$Guess, anchoring$Label, anchoring$Cond)
aaa<- subset(ggg, ggg$anchoring.Cond!="Neutral")
aaa$anchoring.Cond = factor(aaa$anchoring.Cond)
arrange(aaa, aaa$anchoring.Guess)

yyy<-function(iii){
  set.seed(1)
  income_knn = train(anchoring.Cond ~ ., method = "knn", data = iii,
                 trControl = trainControl(method = 'cv', number = 10, 
  returnResamp = "all"))
  return(jjj$results$Accuracy)
} 

  jjj<-(lapply(split(aaa, aaa$anchoring.Label), yyy))
  nnn<-as.data.frame(as.matrix(jjj))

0 个答案:

没有答案