Start FaultTree on R

FaultTree User's Tutorial


Getting started with FaultTree on R

This introduction will cover installation of R and the FaultTree package. R has been selected as the container environment for this open source Fault Tree Analysis software. R is an excellent prototyping environment, although it is not known for its user friendliness. This introduction will hopefully get tentative users off to a running start. Although R is multi-platform environment, this introduction will be made from a Windows user perspective.
A Windows installer for the R environment is available for free download starting at:
Select the download link, then choose a mirror (the first selection always works for me). Here you will view the download links for the three supported operating systems. It does not matter which version of Windows you are using. On a 32-bit installation you will get a 32-bit R system. On a 64-bit system you will get both the 32-bit and the 64-bit installation. Don't worry it doesn't really matter which one you use. We are only concerned with a base installation, click on the 'install R for the first time' link.
It is fine to install with default conditions, however, this creates an MDI application where multiple instances can run in a single container. I find this uncomfortable and prefer the SDI format. Want to try again? Uninstall through the ControlPanel and re-run the installer. This time select a 'custom installation', which will give you a chance to install the SDI format. All the other defaults are fine.

I should mention here that there is a further developer environment that some prefer called R Studio. This application gives an unabashed look and feel of MatLab to R. This is also available as a free download at:
The remainder of this introduction will refer to the simplest R SDI installation. Really we don't need to know much about the R programming language to use FaultTree. Most people find R to have a very steep learning curve, largely due to the stark terminal window that it opens up to. This introduction hopes to guide any first-time user to success.
FaultTree is a package that must be loaded into R. The package is hosted at R-Forge:
From that location navigation would be required by search of Project - ftree. From that location one must select the R Packages link just below the Fault Tree and Event Tree Analysis title button. Or for those in a rush, just load the following URL:
Yes, there is more than one package addressed here. We of course want FaultTree. There are two ways to load this package into your R installation I will walk through both. You can download the .zip file next to the Windows logo. But, do not unzip this as one might expect! Rather, we will open this using the R environment. Run an R instance - as administrator. This is usually accomplished by right clicking on the icon and selecting 'Run as administrator'. I prefer this since only the administrator can load the package into the main R installation, rather than a separate user library. This is a bit of Linux legacy, but we now have users separate from administrator on Windows since Windows 7. Now, in the R Console select the Packages menu item. Then at the bottom of the dropdown menu select 'Install package(s) from local zip files…' Navigate to the location of the downloaded zip from R-forge and open it in R. You should see the following confirmation in the R Console:

> utils:::menuInstallLocal()
package ‘FaultTree’ successfully unpacked and MD5 sums checked

Before continuing, I will mention perhaps an easier method of installation. R-forge provides an automated download and installation command line just underneath the Linux and Windows icons with (.tar.gz) and (.zip) respectively. Generally from the latest version of R (that's what you have if you just downloaded for the first time) -as administrator - you should be able to just copy and paste the installation command directly into the R Console:

install.packages("FaultTree", repos="")


[I once tried this with R version 3.3.1 and it did not work because R-Forge had not gotten around to updating the package build (at version 0.0.9) since R version 3.3.0 . So I got a warning (failure) message for this reason. However the earlier zip method works on all versions.]

This installation operation is only performed once per version of the package. From this point we can use the FaultTree package on each session of R by just mounting the library, which has already been installed in your local file system. This is done by the simple command line directly into the R Console:


This command line only needs to be executed once each R session. That is you can simply open either the 32-bit or the 64-bit R icon by double click and enter this library entry. You may get a warning about the package built under a different R version, but this is only a warning of no significance. There is no harm in making the library call repeatedly, it is just not necessary. Some example scripts might include the library line, perhaps as just a reminder.
To conclude this introduction we will run an example. Copy and paste this script code into the R Console:

tree1 <- ftree.make(type="priority",reversible_cond=TRUE, name="Site power loss")
tree1 <- addLogic(tree1, at=1, type="or", name="neither emergency", name2="generator operable")
tree1 <- addLogic(tree1, at=2, type="and", name="Independent failure", name2="of generators")
tree1 <- addLatent(tree1, at=3, mttf=5,mttr=12/8760,inspect=1/26, name="e-gen set fails")
tree1 <- addLatent(tree1, at=3, mttf=5,mttr=12/8760,inspect=1/26, name="e-gen set fails")
tree1 <- addLogic(tree1, at=2, type="inhibit", name="Common cause", name2="failure of generators")
tree1 <- addProbability(tree1, at=6, prob=.05, name="Common cause", name2="beta factor")
tree1 <- addLatent(tree1, at=6, mttf=5,mttr=12/8760,inspect=1/26, name="e-gen set fails")
tree1 <- addDemand(tree1, at=1, mttf=1.0, name="External power", name2="interruption")
tree1 <- ftree.calc(tree1)

You should see a tabular output of the tree. This is a partial view of the dataframe used to hold the fault tree. For a graphic view it is necessary to write an html file that will then be opened in the default browser. The default location for this file should be the Documents library on Windows.

ftree2html(tree1, write_file=TRUE)

Now the image below should appear in your default browser.