首页 > 解决方案 > R 中与我的代码不匹配的意外符号错误

问题描述

我在 R-studio 中编码,并有一个名为saveResults(). 它需要:

重要的是我收到一条错误消息:

Error: unexpected symbol in:
"saveResults(sce = sce, opt = opt, clusteInputs()
zhengMix"

这与我传递给函数的参数完全不同。您可以在下面代码块的最后一行看到这一点:我传入了正确的参数,但我收到一个错误,说我已经传入clusteInputs(),而zhengMix不是clusterLabels. 我没有一个名为 的函数clusteInputs(),并且zhengMix在上面几行。

# Save the clustering data
InstallAndLoadPackagesForSC3Clustering()
opt <- GetOptionInputs()
zhengMix <- FetchzhengMix(opt)
sce <- CreateSingleCellExperiment(zhengMix)
clusterLabels <- getClusterLabels(sce)
opt <- createNewDirectoriesToSaveData(opt)
saveResults <- function(sce, opt, clusterLabels){
    print("Beginning process of saving results...")
    maxClusters = ncol(clusterLabels)/2+1
    for (n in 2:maxClusters){
        savePCAasPDF(sce, opt, numOfClusters = n, clusterLabels)
        saveClusterLabelsAsRDS(clusterLabels, numOfClusters = n, opt)
    }
    saveSilhouetteScores(sce, opt)
    print("Done.")
}
saveResults(sce = sce, opt = opt, clusterLabels = clusterLabels)

有谁知道发生了什么?我很坚持这一点。

标签: rdebuggingrstudiounexpected-token

解决方案


这不是最好的解决方案,但我通过从函数中删除代码并在那里运行它来解决我自己的问题,没有引起任何问题。


推荐阅读