我在for循环中使用带有条件语句的蜂鸣器功能,但是一旦发出蜂鸣声,就会出现错误“ R会话中止”。有解决此错误的解决方案吗?
BaseRepository br = BaseRepository.clone(repoConfig, new File('c:/temp/local'), remoteRepoURL)
这是我正在使用的代码
答案 0 :(得分:0)
答案去了罗兰。您可以使用Sys.sleep
来引入延迟,并防止beep
消息溢出和随后的R崩溃。请参见下面的代码:
library(beepr)
# data.frame simulation
accdata <- data.frame(
Frame = rnorm(3),
midx = rnorm(3),
midy = rnorm(3),
Object = rnorm(3))
maxFrameDiff <- 100
maxDist <- 100
dupes <- numeric(100)
# cycle with beeps
for (i in 1:(nrow(accdata) - 1)){
row1 <- accdata[i, ]
for(j in (i + 1):nrow(accdata)){
row2 <- accdata[j, ]
if (abs(row1$Frame - row2$Frame) <= maxFrameDiff &&
abs(row1$midx - row2$midx) <= maxDist &&
abs(row1$midy - row2$midy) <= maxDist &&
row1$Object != row2$Object) { # object must be different
dupes <- c(dupes,i,j)
beep()
Sys.sleep(1)
}
}
}