squirrels: Release squirrels.

Description Usage Arguments Value See Also Examples

Description

Add squirrels (for example) at specific locations defined by branch address and distance along branch.

Usage

1
squirrels(x, branches, pos, left = "0", right = "1", plot = TRUE, ...)

Arguments

x

A plant object generated by germinate.

branches

A binary coded vector of addresses of branches upon which squirrels (for example) will be placed. The trunk should be coded as 'Y', while all other elements of branches may only contain the characters given in args left and right. E.g. if left and right are '0' and '1', respectively, then '0' is the first branch to the left stemming from the top of the trunk, while '1' is the first branch to the right, stemming from the top of the trunk; '01' would be a branch forking to the right from the end of the first branch that forked left off the trunk.

pos

A vector whose elements describe the position of squirrels (for example), expressed as the distance from the beginning of the branch. This vector must be the same length as branches, and its elements correspond to the elements of branches.

left

The character used to represent left-turning branches in the branches vector (default is '0'). Must not be 'Y'.

right

The character used to represent right-turning branches in the branches vector (default is '1'). Must not be 'Y'.

plot

Should the points be added to the current plot?

...

Additional arguments controlling the appearance of squirrels (for example), passed to points.

Value

A data.frame with branch addresses (branches), squirrel positions (pos), and the corresponding x and y coordinates. If plot is TRUE, the points will be added to the current plot.

See Also

germinate foliate

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# From http://stackoverflow.com/q/28163979/489704
g <- germinate(list(trunk.height=32,
                    branches=c('0', '1', '00', '01', '010', '011'),
                    lengths=c(21, 19, 5, 12, 6, 2)),
               left='0', right='1', angle=40)

xy <- squirrels(g, c('Y', '0', '010', '0', '00'), pos=c(23, 12, 4, 2, 1), 
                pch=21, bg='white', cex=3, lwd=2)
text(xy$x, xy$y, labels=seq_len(nrow(xy)), font=2)
legend('bottomleft', bty='n',
       legend=paste(seq_len(nrow(xy)), 
                    c('FluffyTail', 'Ginger', 'NutCracker', 'SuperSquirrel', 
                      'ChipnDale'), sep='. '))

johnbaums/trees documentation built on May 19, 2019, 3:03 p.m.