I am profiling R code a lot, and make heavy use of profvis().
For some functions, the top half of the browser window shows the source, and sometimes it doesn't. I can't make out when that is the case, it seems random to me.
Does anyone know when and why profvis can't show the code in the top window? One situation where it happens is this piece of code:
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())
When there is only one function()
in profvis()
, nothing is in upper part of Frame graph. I think the reason is that a function of highlighting a bar at base of graph is unnecessary.
Example code:
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])
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With