Tuesday, April 24, 2012

Plotting Individual tree data in R


>plotvals=read.csv(file.choose())

>plotvals
    comp plot DBH.     xco     yco     zco    height
1    B83    A 11.3  1.1715  2.5170  0.0740  9.447108
2    B83    A 15.9  0.7335  6.5940  0.0020 11.781058
3    B83    A 11.0  0.8530 10.5740 -0.1420  9.294894
4    B83    A 19.1  0.5455 12.8140 -0.1710 13.404675
5    B83    A 11.1  0.7155 14.5720 -0.2460  9.345632

> plot(xco~yco,data=plotvals)


New tutorial here.  
>plot3d(plotvals$xco, plotvals$yco, plotvals$height, pch=16, highlight.3d=TRUE,type="h", main="3D Scatterplot")
My forest is drawni in R! More or less...

And now... using an interesting library called ggplot...

Error: object 'ggplot' not found

First load the library...

> library(ggplot2)
And to extract the column headings as variables


> attach(plotvals)
>df=data.frame(xco,yco,height)
> df
        xco     yco    height
1    1.1715  2.5170  9.447108
2    0.7335  6.5940 11.781058
3    0.8530 10.5740  9.294894
4    0.5455 12.8140 13.404675
p <- ggplot(df, aes(x,y,size=z)) +geom_point()
> p + geom_point() 
Nice!