我对R代码进行了很多分析,并大量使用了profvis()。
对于某些功能,浏览器窗口的上半部分显示了源代码,有时却没有。我无法确定是什么情况,对我来说似乎是随机的。
有谁知道何时以及为什么profvis无法在顶部窗口中显示代码?发生这种情况的一种情况是这段代码:
simulation <- function(p=1e4, n=100){
df <- list()
for(i in 1:p){ # simulate p columns of data
df[[paste0("Var", i)]] <- rnorm(n)
}
df <- as.data.fame(df)
return(apply(df, 2, mean))
}
profvis(simulation())
Run Code Online (Sandbox Code Playgroud)
当 中只有一个function()时profvis(),框架图的上半部分没有任何内容。我认为原因是不需要在图表底部突出显示条形的功能。
示例代码:
library(profvis)
simulation <- function(p=1e4, n=100){
df <- list()
for(i in 1:p){ # simulate p columns of data
df[[paste0("Var", i)]] <- rnorm(n)
}
df <- as.data.frame(df)
return(apply(df, 2, mean))
}
profvis(simulation()) # When only one function() is, the source isn't shown.
profvis({ # When there are more than two function(), source is shown.
simulation()
sum(iris[,1])
})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
649 次 |
| 最近记录: |