How to solve error when using profvis package

Today I learned about the profvis package to make my code faster, from the identification of commands that are demanding more time. The example provided by the package (Profvis — Interactive Visualizations for Profiling R Code) I can run normally, but when I try in my code, nothing happens, it appears: (Sources not available). So I would like to know, what am I doing wrong?

library(dplyr)
library(tidyverse)
library(lubridate)
library(profvis)


df1 <- structure(
    list(Id= c("1","1","2","2"),
         date1= c("2021-06-26","2021-06-26","2021-06-26","2021-06-26"),
         date2 = c("2021-06-27","2021-07-01","2021-07-02","2021-07-02"),
         Category = c("ABC","ABC","ABC","CDE"),
         Week= c("Saturday","Wednesday","Thursday","Thursday"),
         DR1 = c(5,4,1,1),
         DRM01 = c(8,4,1,2), DRM02= c(7,4,2,2),DRM03= c(6,9,5,1),
         DRM04 = c(5,5,4,2),DRM05 = c(5,5,4,2),DRM06 = c(7,5,4,2),DRM07 = c(2,5,4,1),DRM08 = c(2,5,4,2)),
    class = "data.frame", row.names = c(NA, -4L))

 profvis({
 
  x<-df1 %>% select(starts_with("DRM"))
  
  x<-cbind(df1, setNames(df1$DR1 - x, paste0(names(x), "_PV")))
  PV<-select(x,Id, date2,Week, Category, DR1, ends_with("PV"))
  
  med<-PV %>%
    group_by(Id,Category,Week) %>%
    dplyr::summarize(dplyr::across(ends_with("PV"), median),.groups = 'drop')
  
  SPV<-df1%>%
    inner_join(med, by = c('Id','Category', 'Week')) %>%
    mutate(across(matches("^DRM\\d+$"), ~.x + 
                    get(paste0(cur_column(), '_PV')),
                  .names = '{col}_{col}_PV')) %>%
    select(Id:Category, DRM01_DRM01_PV:last_col())

})

enter image description here

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.