Example taf scripts 1 - ices-taf/doc GitHub Wiki
See also: Getting set up, Running a TAF analysis, Creating TAF datasets.
This page was based on using the icesTAF
package version 4.2.0
dated
2023-03-21
.
The resulting TAF analysis created from this example is on GitHub: github.com/ices-taf-dev/wiki-example-3, if you dont want to build up the code yourself by following the example, you can skip to the end and run on your computer by downloading the complete code and running it like this:
# get code
run_dir <- download.analysis("ices-taf-dev/wiki-example-3")
# view downloaded code
browseURL(run_dir)
# run analysis
run.analysis(run_dir)
# view result
browseURL(run_dir)
In this guide
The excercise
In this example the aim is to convert the following simple code, taken
from the help file from the trees
dataset (run ?trees
in R), into
the TAF structure.
# an example (very simple) analysis
# excercise is to move this into a TAF structure
# load data
data(trees)
# some plotting
pairs(trees, panel = panel.smooth, main = "trees data")
plot(Volume ~ Girth, data = trees, log = "xy")
coplot(log(Volume) ~ log(Girth) | Height,
data = trees,
panel = panel.smooth
)
# modeling and summarising
# model
fm1 <- lm(log(Volume) ~ log(Girth), data = trees)
fm2 <- update(fm1, ~ . + log(Height), data = trees)
step(fm2)
summary(fm1)
summary(fm2)
The steps you should follow are:
- Create a
DATA.bib
file - Extract the code for the
data.R
section - Extract the code for the
model.R
section - Extract the code for the
output.R
section - Extract the code for the
report.R
section
At each stage you can test with taf.boot()
and sourceTAF()
as
appropriate, and finally check the whole thing runs by calling
taf.bootsrap(taf=TRUE)
and sourceAll()
.
The answer
The final project should look like this:
example-3
¦--bootstrap
¦ ¦--data
¦ ¦ ¦--cars.csv
¦ ¦ °--trees.csv
¦ ¦--DATA.bib
¦ °--initial
¦ °--data
¦ ¦--cars.csv
¦ °--trees.csv
¦--data
¦ °--trees.csv
¦--data.R
¦--model
¦ °--fits.Rdata
¦--model.R
¦--output
¦ °--tree_fits.csv
¦--output.R
¦--report
¦ ¦--coplot.png
¦ ¦--pairs_plot.png
¦ ¦--scatter_plot.png
¦ °--taf_fits_rnd.csv
°--report.R