r - 在 pycharm 中调试 R 代码:无法运行用户定义的函数?
问题描述
我有一个非常简单的 R 脚本(实际上只是从“真实”脚本中提取的几行......)
suppressPackageStartupMessages(library("klaR"))
suppressPackageStartupMessages(library("caret"))
# The diabetes data has been modified with a header line
wdat <- read.csv('/git/uni/data/pima-indians-diabetes.csv', header=TRUE)
X <- wdat[,-c(9)]
Y <- wdat[,9]
set.seed(1)
xsquared = function(x) { x * x}
for (wi in 1:2) {
ttSplitx <- createDataPartition(y=Y, p=.8, list=FALSE)
Xx <- X
nxTrain <- Xx[ttSplitx, ]
nyTrain <- Y[ttSplitx]
labelTrue <- nyTrain>0
posCnt <- nxTrain[labelTrue, ]
negCnt <- nxTrain[!labelTrue,]
posMean <- sapply(posCnt, mean, na.rm=TRUE)
posSd <- sapply(posCnt, sd, na.rm=TRUE)
posOffsets <- t(t(nxTrain)-posMean)
posScaled <- t(t(posOffsets)/posSd)
posLogs <- -(1/2)*rowSums(apply(posScaled,c(1, 2),
function(x) { x * x} ), na.rm=TRUE)-sum(log(posSd)) # Line 25
# function(x) { xsquared(x) }), na.rm=TRUE)-sum(log(posSd)) # Line 26
}
print('done')
上面的代码在启用调试的情况下运行大约三秒钟。
但是当line26
使用而不是line25
通过交换评论时 - 它会运行但在调试模式下会无限期挂起。
posLogs <- -(1/2)*rowSums(apply(posScaled,c(1, 2),
#function(x) { x * x} ), na.rm=TRUE)-sum(log(posSd)) # Line 25
function(x) { xsquared(x) }), na.rm=TRUE)-sum(log(posSd)) # Line 26
这明确表明pycharm
无法调试到
xsquared = function(x) { x * x}
对于我尝试定义的任何函数都是如此。
那么..为什么不能通过pycharm
R
调试器调用用户函数?
解决方案
插件开发人员提出了一个问题,他们回应说该功能目前不可用。
推荐阅读
- pytorch - 在 Anaconda 中导入 pytorch 时出现问题
- postgresql - Sequelize – 按值排序
- sql - 如何使用更新在嵌套子查询中使用外部查询变量?
- r - 如何在 R 中创建以下函数?
- xampp - 我在哪里可以将我的网站文件夹粘贴到 Ubuntu XAMPP 中以访问本地主机服务器?
- elasticsearch - 在 Elasticsearch 搜索结果中跳过字段中的重复项
- flutter - 如何在颤动中制作 Windows 通知?
- python - 来自两列 DataFrame 的 Pandas Series 产生一系列 NaN
- rust - 如何将项目从函数参数推送到函数参数的向量 - 不同的生命周期问题
- python - Is there a way to call multiple get and post requests in a flask appfrom an IOS app