3
you know some package in R that concatenates and makes 2D and 3D graphics faster than ggplot2?
3
you know some package in R that concatenates and makes 2D and 3D graphics faster than ggplot2?
5
The very one base
is much faster than the ggplot2
in terms of the time to render the chart.
> library(ggplot2)
> dados <- data.frame(x = 1:10, y = 1:10)
> microbenchmark::microbenchmark(
+ base = plot(dados$x, dados$y),
+ ggplot2 = print(ggplot(dados, aes(x, y)) + geom_point()),
+ times = 10)
Unit: milliseconds
expr min lq mean median uq max neval
base 6.111439 6.297696 11.23991 13.0963 13.68068 14.21597 10
ggplot2 137.465155 139.280801 148.73481 148.4097 155.98191 161.27931 10
But if you are having problems because ggplot is taking its time you should consider taking a sample of your data to make the graph. Usually for viewing should not make much difference.
If you are trying to make frequency charts, you can try grouping the data using some oputro package and then using ggplot only to plot. For example, if you wanted to make a bar graph of the colors of diamonds (database diamonds
of R).
Could do so:
diamonds %>%
group_by(color) %>%
summarise(n = n()) %>%
ggplot(aes(x = color, y = n)) +
geom_bar(stat = "identity")
Instead of doing like this:
ggplot(diamonds, aes(x = color)) + geom_bar()
The way using the dplyr
will be a little faster:
Unit: milliseconds
expr min lq mean median uq max neval
ggplot + dplyr 154.2552 159.4668 165.0565 162.5604 172.0724 180.2274 10
ggplot 205.3213 212.5129 218.5641 217.9931 223.3510 238.7627 10
Browser other questions tagged r
You are not signed in. Login or sign up in order to post.