googleVis 0.7.0 adds Gantt charts
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Version 0.7.0 of the googleVis R package has been released, adding a new function for Gantt charts. Gantt charts are helpful to illustrates a project schedule and its dependencies.
Following the Google documentation the project has to be broken down into task IDs, task names, resources, start date, end dates, task duration (in milliseconds), how far the task has been completed (in percent), and finally any dependencies to other tasks IDs.
Here is an example for a project to write a research paper:
# Helper function daysToMilliseconds <- function(days){ days * 24 * 60 * 60 * 1000 } # Project outline dat <- data.frame( taskID = c("Research", "Write", "Cite", "Complete", "Outline"), taskName = c("Find sources", "Write Paper", "Create bibliography", "Hand in paper", "Outline paper"), resource = c(NA, "write", "write", "complete", "write"), start = c(as.Date("2022-01-01"), NA, NA, NA, NA), end = as.Date(c("2022-01-05", "2022-01-09", "2022-01-07", "2022-01-10", "2022-01-06")), duration = c(NA, daysToMilliseconds(c(3, 1, 1, 1))), percentComplete = c(100, 25, 20, 0, 100), dependencies = c(NA, "Research, Outline", "Research", "Cite, Write", "Research")) dat ## taskID taskName resource start end duration ## 1 Research Find sources <NA> 2022-01-01 2022-01-05 NA ## 2 Write Write Paper write <NA> 2022-01-09 259200000 ## 3 Cite Create bibliography write <NA> 2022-01-07 86400000 ## 4 Complete Hand in paper complete <NA> 2022-01-10 86400000 ## 5 Outline Outline paper write <NA> 2022-01-06 86400000 ## percentComplete dependencies ## 1 100 <NA> ## 2 25 Research, Outline ## 3 20 Research ## 4 0 Cite, Write ## 5 100 Research
To create a Gantt chart we load the googleVis package and use the
gvisGantt
function, mapping the various columns in our data to the
relevant arguments:
library(googleVis) gntt <- gvisGantt(dat, taskID = "taskID", taskName = "taskName", resource = "resource", start = "start", end = "end", duration = "duration", percentComplete = "percentComplete", dependencies = "dependencies", options = list(height='300', width = 'auto'))
Finally, we can display the Gantt chart using the plot
method:
plot(gntt)
For more information about the googleVis package and other visualisation methods visit: https://mages.github.io/googleVis/
Session info
sessionInfo() ## R version 4.2.0 (2022-04-22) ## Platform: aarch64-apple-darwin20 (64-bit) ## Running under: macOS Monterey 12.3.1 ## ## Matrix products: default ## BLAS: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRblas.0.dylib ## LAPACK: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRlapack.dylib ## ## locale: ## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 ## ## attached base packages: ## [1] stats graphics grDevices utils datasets methods base ## ## other attached packages: ## [1] googleVis_0.7.0 ## ## loaded via a namespace (and not attached): ## [1] bookdown_0.26 codetools_0.2-18 digest_0.6.29 R6_2.5.1 ## [5] jsonlite_1.8.0 magrittr_2.0.3 evaluate_0.15 blogdown_1.10 ## [9] stringi_1.7.6 rlang_1.0.2 cli_3.3.0 rstudioapi_0.13 ## [13] jquerylib_0.1.4 bslib_0.3.1 rmarkdown_2.14 tools_4.2.0 ## [17] stringr_1.4.0 xfun_0.31 yaml_2.3.5 fastmap_1.1.0 ## [21] compiler_4.2.0 htmltools_0.5.2 knitr_1.39 sass_0.4.1
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.