Profiling in RStudio - profvis() not giving desired outputs

Viewed 222

I am trying to learn how to profile in R, and am in need of some help. I am using the profvis() function, and am following the examples both in Chapter 7 of Colin Gillespie's Efficient R programming, and the Rstudio support page for profiling: https://support.rstudio.com/hc/en-us/articles/218221837-Profiling-with-RStudio.

However, when I run the same code as their examples, I am not getting the same outputs. For example:

library("profvis")
profvis({
  data(movies, package = "ggplot2movies") # Load data
  movies = movies[movies$Comedy == 1,]
  plot(movies$year, movies$rating)
  model = loess(rating ~ year, data = movies) # loess regression line
  j = order(movies$year)
 lines(movies$year[j], model$fitted[j]) # Add line to the plot
})

I should be getting an output like this:

Efficient R Output

but instead I am getting an output like this: My output

In fact, this output isn't always consistent (for example, sometimes sources not available), but always has the "profvis" as the bottom of the flame graph, which is not the case with any examples I've seen.

I have a similar problem when running the example from the RStudio support page:

library(profvis)
profvis({
  data(diamonds, package = "ggplot2")

  plot(price ~ carat, data = diamonds)
  m <- lm(price ~ carat, data = diamonds)
  abline(m, col = "red")
})

Support Page Output

But after running the code three times in a row, here are my 3 outputs, all with the profvis in the flame graph:

Output_1

Output_2

Output_3

Also, one last note: I have fully updated R and RStudio and this did not help.

I am very confused as to why this is happening, and can't find any examples of this online. I hope I'm not missing anything obvious, and would greatly appreciate any help.

Thanks.

0 Answers
Related