Rev 802 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | |||
791 | werner | 2 | ### |
3 | ### load some useful tools/functions |
||
4 | #source("sql_tools.R") |
||
5 | library(RSQLite) |
||
6 | |||
7 | # connect to an existing database |
||
8 | db.conn <<- dbConnect("SQLite", dbname="e:/Daten/iLand/projects/AFJZ_experiment1203/output/bare_soil_afi413.sqlite" ) |
||
9 | |||
10 | ### load data from the iLand output table |
||
11 | stand <- dbReadTable(db.conn, "stand") |
||
12 | # alternatively (using sql_tools): stand <- query("select * from stand") |
||
13 | |||
14 | summary(stand) |
||
15 | |||
16 | ## stacked bar chart, e.g. for basal area |
||
17 | library(ggplot2) |
||
18 | |||
19 | head(stand) |
||
20 | # aggregate to values for each species and year (i.e. averaging over all the resource units) |
||
21 | stand.avg <- aggregate(stand, list(year=stand$year, species=stand$species), FUN="mean") |
||
22 | head(stand.avg) |
||
23 | |||
24 | # now we can plot them: |
||
25 | ggplot(stand.avg, aes(x=year,y=basal_area_m2,group=species,fill=species)) + geom_area() + labs(xlab="year", ylab="basal area m2", title="average basal area") |
||
26 | ## stem numbers |
||
27 | ggplot(stand.avg, aes(x=year,y=count_ha,group=species,fill=species)) + geom_area() |
||
28 | ggplot(stand.avg, aes(x=year,y=cohortCount_ha,group=species,fill=species)) + geom_area() |
||
29 | |||
30 | ggplot(stand.avg, aes(x=year,y=LAI,group=species,fill=species)) + geom_area() |