This package provides the functionality to create UML graphs using the PlantUML language.
The actual work is done by the program plantuml. Please see the plantuml installation page for prerequisites of running plantuml. You don’t have tio install the plantuml.jar file, as the packagae maintains it’s own version (see below).
As the package is only on github, you need devtools
to install it
easily as a prerequisite
install.packages("devtools")
The package is not on CRAN, so you have to install it from github. Also, it doez not come with the plantuml binary, which needs to be installed as well:
# Install plantuml from github
devtools::install_github("rkrug/plantuml")
# download and install the PlantUML jar file from \link{http://plantuml.com/download}
# whenever you call this command again, the plantuml binary will be updated to the newest version
library(plantuml)
updatePlantumlJar()
First, we define a plantuml object based on some plantuml code
library(plantuml)
x <- '
(*) --> "Initialization"
if "Some Test" then
-->[true] "Some Activity"
--> "Another activity"
-right-> (*)
else
->[false] "Something else"
-->[Ending process] (*)
endif
'
x <- plantuml(
x
)
Now we plot in in a device using vector format (svg) as intermediate format, which is the default
plot(
x = x
# vector = TRUE
)
When using vector = FALSE
uses a raster format (png) as intermediate
format
plot(
x = x,
vector = FALSE
)
To save the graph in a file, we simply specify the file
argument in
the plot command:
plot(
x,
file = "./README_files/test.svg"
)
And here is the file
The type of the file is automatically determined based on the extension. Suported extensions in plantuml are:
- png To generate images using PNG format (default)
- svg To generate images using SVG format
- eps To generate images using EPS format
- pdf To generate images using PDF format
- vdx To generate images using VDX format
- xmi To generate XMI file for class diagram
- scxml To generate SCXML file for state diagram
- html To generate HTML file for class diagram
- txt To generate images with ASCII art
- utxt To generate images with ASCII art using Unicode characters
- latex To generate images using LaTeX/Tikz format
- latex:nopreamble To generate images using LaTeX/Tikz format without preamble
In addition to plotting based on plantuml code some basic functionality to document R objects has been included.
This is not much more than a proof of concept but includes all standard R objects.
If you think this is usefull, pelase let me know and leave sugestions in the issue tracker.
One example is:
x <- list(
a = 1:10,
b = letters[1:4],
c = data.frame(
x = 1:10,
y = c(TRUE, FALSE)
)
)
plot(
as.plantuml(x)
)
- make selection dependant on installed packages, as
vector = TRUE
requires postscript to be installed! - update documentation and
- add tests for
plot.plantuml()