¿Sabes como se ha generado este árbol de Navidad? Solo tienes que ejecutar la sintáxis de abajo en la consola de R project y lo tienes listo.
Sintáxis de R (copia y pega en la consola)
part <- list="" x0="0,y0=0,x1=0,y1=1,<br"> branch1=NULL,branch2=NULL,extend=NULL,
lwd=1,depth=0,col='springgreen')
par(mfrow=c(1,1),mar=c(5, 4, 4, 2) + 0.1)
segplot <- br="" function="" tree=""> if (is.null(tree)) return()
segments(tree$x0,tree$y0,tree$x1,tree$y1,
col=tree$col,
lwd=tree$lwd)
segplot(tree$branch1)
segplot(tree$branch2)
segplot(tree$extend)
}
#segplot(part)
grow <- br="" function="" tree=""> if (is.null(tree) ) return(NULL)
tree$lwd=tree$lwd*1.2
if (tree$lwd>2.5) tree$col <- br="" brown=""> if (is.null(tree$extend)) {
tree$extend <- br="" list=""> x0=tree$x1,
y0=tree$y1,
x1=rnorm(1,1,.03)*(2*tree$x1-tree$x0),
y1=(rnorm(1,.98,.02)+.02*(tree$x1==tree$x0))*(2*tree$y1-tree$y0),
branch1=NULL,
branch2=NULL,
extend=NULL,
lwd=1,
depth=tree$depth,
col=tree$col
)
length=sqrt((tree$x1-tree$x0)^2 + (tree$y1-tree$y0)^2)
angle <- asin="" br="" length="" tree="" x0="" x1-tree=""> branch <- br="" list=""> x0=(tree$x1+tree$x0)/2,
y0=(tree$y1+tree$y0)/2,
branch1=NULL,
branch2=NULL,
extend=NULL,
lwd=1,
depth=tree$depth,
col=tree$col
)
shift <- br="" rnorm=""> branch$x0 <- br="" shift="" tree="" x0="" x1=""> branch$y0 <- br="" shift="" tree="" y0="" y1=""> length=length*rnorm(1,.5,.05)
co <- br="" runif=""> branch$x1 <- angle="" br="" branch="" co="" length="" sin="" x0=""> branch$y1 <- angle="" br="" branch="" co="" cos="" length="" y0=""> tree$branch1 <- br="" branch=""> branch$x0 <- br="" shift="" tree="" x0="" x1=""> branch$y0 <- br="" shift="" tree="" y0="" y1=""> co <- br="" runif=""> branch$x1 <- angle-co="" br="" branch="" length="" sin="" x0=""> branch$y1 <- angle-co="" br="" branch="" cos="" length="" y0=""> tree$branch2 <- br="" branch="" nbsp=""> } else {
tree$branch1 <- br="" branch1="" grow="" tree=""> tree$branch2 <- br="" branch2="" grow="" tree=""> tree$extend <- br="" extend="" grow="" tree=""> }
tree$depth <- br="" depth="" tree=""> if (tree$depth>2) tree$col <- br="" green=""> if (tree$depth>4) tree$col <- br="" darkgreen=""> if (tree$depth>6) tree$col <- br="" brown="">
tree
}
tree <- br="" part=""> for (i in 1:9) tree <- br="" grow="" nbsp="" tree=""> par(mar=c(0,0,0,0))
plot(x=c(-3,3),y=c(0,9),type='n',axes=FALSE,xlab='',ylab='')
segplot(tree)->->->->->->->->->->->->->->->->->->->->->->->->->->->->->
Fuente: http://wiekvoet.blogspot.com.es/2013/12/merry-christmas.html?m=1
No hay comentarios:
Publicar un comentario