setwd('/media/Data/skola/dipl/data/csv/working')
# load data
gener.small <- read.table('generMPlot.csv', head=T)
gener.130 <- read.table('gener130Plot.csv', head=T)
veget <- read.table('vegetPlot.csv', head=T)
trees.plot <- read.table('treesPlot.csv', head=T)
trees.50 <- read.table('trees50.csv', head=T)
trees.landscape <- read.table('landscape.csv', head=T)
trees.closest <- read.table('treesClosest.csv', head=T)
humid <- read.table('humidPlot.csv', head=T)
light <- read.table('light.csv', head=T)
soil <- read.table('soil.csv', head=T)
opakovani <- veget$opakovani
plocha <- veget$plocha
treatment <- veget$treatment
plot <- row.names(veget)
range01 <- function(x){if (max(x)==min(x)) rep(0, length(x)) else (x-min(x))/(max(x)-min(x))}
file.eda <- function(name) paste0('../../graphs/eda/', name)
distanceClass <- function(dist) sapply(dist,
function(x) if (x<50) 1 else
if (x<100) 2 else
if (x<200) 3 else 4)
count.scales <- matrix(c(5, 15, 50, 10, 50, 150, 100, 500, 2000), byrow=T, nrow=3)
countClass <- function(count, scale) {
sapply(count, function(x) if (x<count.scales[scale, 1]) 1
else if(x<count.scales[scale, 2]) 2
else if (x<count.scales[scale, 3]) 3 else 4)
}
# Codes values into colors: gray when zero, black otherwise
grayIfZero <- function(x, zero=0, black='black', gray='#999999') {
c(black, gray)[(x==zero)+2-1]
}
plotVariable <- function(var, file.name, x.axis, log='') {
pdf(file.eda(file.name), height=11, width=7.5, paper='a4')
par(mfrow=c(6,1), mar=c(4, 3, 2, .3))
for (i in c('ac', 'cb', 'fx', 'q', 'rp', 'tc')) {
values.high.which <- which(unlist(gener.130[paste0(i, '.sum')]) > 0)
values.high <- unlist(gener.130[paste0(i, '.sum')])[values.high.which]
values.low <- unlist(gener.small[paste0(i, '.sum')])
values.closest <- unlist(trees.closest[i])
plot(c(var[order(values.low)], var[values.high.which]),
c(sort(values.low), values.high),
xlab='', ylab='',
log=log,
pch=c(rep(1, length(values.low)), rep(16, length(values.high))),
#pch=as.numeric(c(plocha[order(values.low)], plocha[values.high.which])),
#cex=range01(c(values.closest[order(values.low)], values.closest[values.high.which]))*3 + 1,
cex=distanceClass(c(values.closest[order(values.low)], values.closest[values.high.which])),
col=grayIfZero(c(sort(values.low), values.high)),
main=tree.labels[i])
if(i=='ac') {
legend('topleft', c('nízké', 'vysoké'), pch=c(1, 16, 1, 1), bty='n',
horiz=T, inset=c(0, -.25), xpd=T)
legend('topright', c('<50 m', '<100 m', '<200 m', '>200 m'), pch=1, bty='n', horiz=T,
text.width=strwidth('>200 m') * 1.2,
pt.cex=c(1, 2, 3, 4), y.intersp=1.6, x.intersp=1.3, inset=-c(.01, .3), xpd=T)
mtext(side=1, x.axis, line=2.2, cex=.7)
mtext(side=2, 'četnost zmlazení', line=2.2, cex=.7)
par(mar=c(2.5, 3, 2, 0.3))
}
}
dev.off()
}
plotVarScales <- function(tree, var, var.abb, x.axis, dir='', type='sum', log='') {
inset.x <- .03
inset.y <- .15
file.name <- paste(tree, type, var.abb, sep='-')
if (dir != '') file.name <- paste0(dir, '/', file.name)
if (log=='y') file.name <- paste(file.name, 'logy', sep='-')
file.name <- paste(file.name, 'scales.pdf', sep='-')
pdf(file.eda(file.name), height=7.5, width=11, paper='a4r')
par(mfrow=c(2,2), mar=c(4, 3, 3, .3))
var <- unlist(var)
values.high.which <- which(unlist(gener.130[paste(tree, type, sep='.')]) > 0)
values.high <- unlist(gener.130[paste(tree, type, sep='.')])[values.high.which]
values.low <- unlist(gener.small[paste(tree, type, sep='.')])
values.trees <- unlist(trees.closest[tree])
plot(c(var[order(values.low)], var[values.high.which]),
c(sort(values.low), values.high) + (log != ''),
xlab='', ylab='',
log=log,
pch=c(rep(1, length(values.low)), rep(16, length(values.high))),
#pch=as.numeric(c(plocha[order(values.low)], plocha[values.high.which])),
#cex=range01(c(values.closest[order(values.low)], values.closest[values.high.which]))*3 + 1,
cex=distanceClass(c(values.trees[order(values.low)], values.trees[values.high.which])),
col=grayIfZero(c(sort(values.low), values.high)))
legend('topleft', c('nízké', 'vysoké'), pch=c(1, 16, 1, 1), bty='n',
horiz=T, inset=c(-.013, -.135), xpd=T)
legend('topright', c('<50 m', '<100 m', '<200 m', '>200 m'), pch=1, bty='n', horiz=T,
text.width=strwidth('>200 m') * 1.2,
pt.cex=c(1, 2, 3, 4), y.intersp=1.6, x.intersp=1.3, inset=-c(inset.x, inset.y), xpd=T)
mtext(side=1, x.axis, line=2.2, cex=.7)
mtext(side=2, paste(if (type=='sum') 'četnost' else 'pokryvnost', 'zmlazení'), line=2.2, cex=.7)
mtext(side=3, tree.labels[which(names(tree.names)==tree)], line=1.8, adj=0)
mtext(side=3, 'vzdálenost nejbližšího fertilního jedince', line=1.9, adj=1, cex=.8)
values.trees <- unlist(trees.plot[paste0(tree, '.cover')])
plot(c(var[order(values.low)], var[values.high.which]),
c(sort(values.low), values.high) + (log != ''),
xlab='', ylab='',
log=log,
pch=c(rep(1, length(values.low)), rep(16, length(values.high))),
#pch=as.numeric(c(plocha[order(values.low)], plocha[values.high.which])),
#cex=range01(c(values.closest[order(values.low)], values.closest[values.high.which]))*3 + 1,
cex=countClass(c(values.trees[order(values.low)], values.trees[values.high.which]), 1),
col=grayIfZero(c(sort(values.low), values.high)),
main=tree.labels[tree])
legend('topright', c(paste0('<', count.scales[1, ]), paste0('>', tail(count.scales[1, ], 1))),
pch=1, bty='n', horiz=T,
text.width=strwidth('>200 m') * 1.2,
pt.cex=c(1, 2, 3, 4), y.intersp=1.6, x.intersp=1.3, inset=-c(inset.x + .05, inset.y), xpd=T)
mtext(side=3, 'počet fertilních jedinců na ploše', line=1.9, adj=1, cex=.8)
values.trees <- unlist(trees.50[tree])
plot(c(var[order(values.low)], var[values.high.which]),
c(sort(values.low), values.high) + (log != ''),
xlab='', ylab='',
log=log,
pch=c(rep(1, length(values.low)), rep(16, length(values.high))),
#pch=as.numeric(c(plocha[order(values.low)], plocha[values.high.which])),
#cex=range01(c(values.closest[order(values.low)], values.closest[values.high.which]))*3 + 1,
cex=countClass(c(values.trees[order(values.low)], values.trees[values.high.which]), 2),
col=grayIfZero(c(sort(values.low), values.high)),
main=tree.labels[tree])
legend('topright', c(paste0('<', count.scales[2, ]), paste0('>', tail(count.scales[2, ], 1))),
pch=1, bty='n', horiz=T,
text.width=strwidth('>200 m') * 1.2,
pt.cex=c(1, 2, 3, 4), y.intersp=1.6, x.intersp=1.3, inset=-c(inset.x + .04, inset.y), xpd=T)
mtext(side=3, 'počet fertilních jedinců do 50 m', line=1.9, adj=1, cex=.8)
values.trees <- unlist(trees.landscape[tree])
plot(c(var[order(values.low)], var[values.high.which]),
c(sort(values.low), values.high) + (log != ''),
xlab='', ylab='',
log=log,
pch=c(rep(1, length(values.low)), rep(16, length(values.high))),
#pch=as.numeric(c(plocha[order(values.low)], plocha[values.high.which])),
#cex=range01(c(values.closest[order(values.low)], values.closest[values.high.which]))*3 + 1,
cex=countClass(c(values.trees[order(values.low)], values.trees[values.high.which]), 3),
col=grayIfZero(c(sort(values.low), values.high)),
main=tree.labels[tree])
legend('topright', c(paste0('<', count.scales[3, ]), paste0('>', tail(count.scales[3, ], 1))),
pch=1, bty='n', horiz=T,
text.width=strwidth('>200 m') * 1.2,
pt.cex=c(1, 2, 3, 4), y.intersp=1.6, x.intersp=1.3, inset=-c(inset.x + .02, inset.y), xpd=T)
mtext(side=3, 'počet fertilních jedinců do 500 m', line=1.9, adj=1, cex=.8)
dev.off()
}
coords.plots <- readOGR("../../gis", layer="plotsSel")
tree.names <- c('Acer campestre', 'Acer platanoides', 'Acer pseudoplatanus', 'Betula pendula',
'Carpinus betulus', 'Fraxinus sp.', 'Larix decidua', 'Pinus sylvestris',
'Populus tremula', 'Quercus sp.', 'Robinia pseudacacia', 'Sorbus torminalis',
'Tilia sp.', 'Quercus rubra', 'Aesculus hippocastanum', 'Alnus glutinosa',
'Picea abies', 'Quercus frainetto', 'Quercus cerris', 'Acer negundo',
'Salix fragilis', 'Salix caprea', 'Quercus pubescens', 'Prunus avium',
'Pinus nigra', 'Populus x canadensis')
tree.names.sp <- grep(' sp[.]$', tree.names) # indices of unspecific tree names
tree.names.cut <- sub(' sp[.]$', '', tree.names) # cutting ' sp.' from tree names
# preparing tree name labels to be printed in italic but with ' .sp' in regular font
tree.labels <- sapply(tree.names.cut, function(tn) as.expression(substitute(italic(x), list(x=tn))))
for (i in tree.names.sp) tree.labels[[i]] <-
substitute(paste(italic(x), y), list(x=tree.names.cut[i], y=' sp.'))
tree.names.xml <- c('<latin>Acer campestre</latin>', '<latin>Acer platanoides</latin>',
'<latin>Acer pseudoplatanus</latin>', '<latin>Betula pendula</latin>',
'<latin>Carpinus betulus</latin>', '<latin>Fraxinus</latin> sp.',
'<latin>Larix decidua</latin>', '<latin>Pinus sylvestris</latin>',
'<latin>Populus tremula</latin>', '<latin>Quercus</latin> sp.',
'<latin>Robinia pseudacacia</latin>', '<latin>Sorbus torminalis</latin>',
'<latin>Tilia</latin> sp.', '<latin>Quercus rubra</latin>',
'<latin>Aesculus hippocastanum</latin>', '<latin>Alnus glutinosa</latin>',
'<latin>Picea abies</latin>', '<latin>Quercus frainetto</latin>',
'<latin>Quercus cerris</latin>', '<latin>Acer negundo</latin>',
'<latin>Salix fragilis</latin>', '<latin>Salix caprea</latin>',
'<latin>Quercus pubescens</latin>', '<latin>Prunus avium</latin>',
'<latin>Pinus nigra</latin>', '<latin>Populus &times; canadensis</latin>')
names(tree.names) <- c("ac", "apla", "apse", "bp", "cb", "fx", "lx", "ps", "pt", "q",
"rp", "st", "tc", "qr", 'ah', 'aglu', 'pa', 'qf', 'qc', 'aneg', 'sxfr', 'sxcap', 'qpub',
'prua', 'pnig', 'pcan')
cols <- 6:ncol(soil)
col.labels <- c('Ca', 'Mg', 'C/N', 'P', 'K', 'N', 'C', 'pH')
for (tree in c('ac', 'cb', 'fx', 'q', 'rp', 'tc')) {
for (var in 1:8) {
plotVarScales(tree, soil[, var+5], names(soil)[var+5], col.labels[var],
'sum', log='y', dir='spe-var/log')
plotVarScales(tree, soil[, var+5], names(soil)[var+5], col.labels[var], 'sum', dir='spe-var')
}
plotVarScales(tree, trees.plot$cover, 'light', 'pokryvnost stromového patra',
type='cover', dir='spe-var/log', log='y')
plotVarScales(tree, humid$humid, 'humid', 'vlhkost', type='sum', dir='spe-var/log', log='y')
plotVarScales(tree, trees.plot$cover, 'light', 'pokryvnost stromového patra',
type='cover', dir='spe-var')
plotVarScales(tree, humid$humid, 'humid', 'vlhkost', type='sum', dir='spe-var')
}
plotVariable <- function(var, file.name, x.axis, log='') {
pdf(file.eda(file.name), height=11, width=7.5, paper='a4')
par(mfrow=c(6,1), mar=c(4, 3, 2, .3))
for (i in c('ac', 'cb', 'fx', 'q', 'rp', 'tc')) {
values.high.which <- which(unlist(gener.130[paste0(i, '.sum')]) > 0)
values.high <- unlist(gener.130[paste0(i, '.sum')])[values.high.which]
values.low <- unlist(gener.small[paste0(i, '.sum')])
values.closest <- unlist(trees.closest[i])
plot(c(var[order(values.low)], var[values.high.which]),
c(sort(values.low), values.high),
xlab='', ylab='',
log=log,
pch=c(rep(1, length(values.low)), rep(16, length(values.high))),
pch=as.numeric(c(plocha[order(values.low)], plocha[values.high.which])),
cex=range01(c(values.closest[order(values.low)], values.closest[values.high.which]))*3 + 1,
cex=distanceClass(c(values.closest[order(values.low)], values.closest[values.high.which])),
col=grayIfZero(c(sort(values.low), values.high)),
main=tree.labels[i])
if(i=='ac') {
legend('topleft', c('nízké', 'vysoké'), pch=c(1, 16, 1, 1), bty='n',
horiz=T, inset=c(0, -.25), xpd=T)
legend('topright', c('<50 m', '<100 m', '<200 m', '>200 m'), pch=1, bty='n', horiz=T,
text.width=strwidth('>200 m') * 1.2,
pt.cex=c(1, 2, 3, 4), y.intersp=1.6, x.intersp=1.3, inset=-c(.01, .3), xpd=T)
mtext(side=1, x.axis, line=2.2, cex=.7)
mtext(side=2, 'četnost zmlazení', line=2.2, cex=.7)
par(mar=c(2.5, 3, 2, 0.3))
}
}
dev.off()
}
plotVariable(soil$ca, 'ca-spe.pdf', 'Ca')
plotVariable <- function(var, file.name, x.axis, log='') {
pdf(file.eda(file.name), height=11, width=7.5, paper='a4')
par(mfrow=c(6,1), mar=c(4, 3, 2, .3))
for (i in c('ac', 'cb', 'fx', 'q', 'rp', 'tc')) {
values.high.which <- which(unlist(gener.130[paste0(i, '.sum')]) > 0)
values.high <- unlist(gener.130[paste0(i, '.sum')])[values.high.which]
values.low <- unlist(gener.small[paste0(i, '.sum')])
values.closest <- unlist(trees.closest[i])
plot(c(var[order(values.low)], var[values.high.which]),
c(sort(values.low), values.high),
xlab='', ylab='',
log=log,
#pch=c(rep(1, length(values.low)), rep(16, length(values.high))),
pch=as.numeric(c(plocha[order(values.low)], plocha[values.high.which])),
cex=range01(c(values.closest[order(values.low)], values.closest[values.high.which]))*3 + 1,
cex=distanceClass(c(values.closest[order(values.low)], values.closest[values.high.which])),
col=grayIfZero(c(sort(values.low), values.high)),
main=tree.labels[i])
if(i=='ac') {
legend('topleft', c('nízké', 'vysoké'), pch=c(1, 16, 1, 1), bty='n',
horiz=T, inset=c(0, -.25), xpd=T)
legend('topright', c('<50 m', '<100 m', '<200 m', '>200 m'), pch=1, bty='n', horiz=T,
text.width=strwidth('>200 m') * 1.2,
pt.cex=c(1, 2, 3, 4), y.intersp=1.6, x.intersp=1.3, inset=-c(.01, .3), xpd=T)
mtext(side=1, x.axis, line=2.2, cex=.7)
mtext(side=2, 'četnost zmlazení', line=2.2, cex=.7)
par(mar=c(2.5, 3, 2, 0.3))
}
}
dev.off()
}
plotVariable(soil$ca, 'ca-spe.pdf', 'Ca')
plotVariable <- function(var, file.name, x.axis, log='') {
pdf(file.eda(file.name), height=11, width=7.5, paper='a4')
par(mfrow=c(6,1), mar=c(4, 3, 2, .3))
for (i in c('ac', 'cb', 'fx', 'q', 'rp', 'tc')) {
values.high.which <- which(unlist(gener.130[paste0(i, '.sum')]) > 0)
values.high <- unlist(gener.130[paste0(i, '.sum')])[values.high.which]
values.low <- unlist(gener.small[paste0(i, '.sum')])
values.closest <- unlist(trees.closest[i])
plot(c(var[order(values.low)], var[values.high.which]),
c(sort(values.low), values.high),
xlab='', ylab='',
log=log,
#pch=c(rep(1, length(values.low)), rep(16, length(values.high))),
pch=as.numeric(c(plocha[order(values.low)], plocha[values.high.which])),
#cex=range01(c(values.closest[order(values.low)], values.closest[values.high.which]))*3 + 1,
cex=distanceClass(c(values.closest[order(values.low)], values.closest[values.high.which])),
col=grayIfZero(c(sort(values.low), values.high)),
main=tree.labels[i])
if(i=='ac') {
legend('topleft', c('nízké', 'vysoké'), pch=c(1, 16, 1, 1), bty='n',
horiz=T, inset=c(0, -.25), xpd=T)
legend('topright', c('<50 m', '<100 m', '<200 m', '>200 m'), pch=1, bty='n', horiz=T,
text.width=strwidth('>200 m') * 1.2,
pt.cex=c(1, 2, 3, 4), y.intersp=1.6, x.intersp=1.3, inset=-c(.01, .3), xpd=T)
mtext(side=1, x.axis, line=2.2, cex=.7)
mtext(side=2, 'četnost zmlazení', line=2.2, cex=.7)
par(mar=c(2.5, 3, 2, 0.3))
}
}
dev.off()
}
plotVariable(soil$ca, 'ca-spe.pdf', 'Ca')
?dev.off
dev.list()
dev.off()
dev.off()
plotVariable <- function(var, file.name, x.axis, log='') {
pdf(file.eda(file.name), height=11, width=7.5, paper='a4')
par(mfrow=c(6,1), mar=c(4, 3, 2, .3))
for (i in c('ac', 'cb', 'fx', 'q', 'rp', 'tc')) {
values.high.which <- which(unlist(gener.130[paste0(i, '.sum')]) > 0)
values.high <- unlist(gener.130[paste0(i, '.sum')])[values.high.which]
values.low <- unlist(gener.small[paste0(i, '.sum')])
values.closest <- unlist(trees.closest[i])
plot(c(var[order(values.low)], var[values.high.which]),
c(sort(values.low), values.high) + (log!=''),
xlab='', ylab='',
log=log,
#pch=c(rep(1, length(values.low)), rep(16, length(values.high))),
pch=as.numeric(c(plocha[order(values.low)], plocha[values.high.which])),
#cex=range01(c(values.closest[order(values.low)], values.closest[values.high.which]))*3 + 1,
cex=distanceClass(c(values.closest[order(values.low)], values.closest[values.high.which])),
col=grayIfZero(c(sort(values.low), values.high)),
main=tree.labels[i])
if(i=='ac') {
legend('topleft', c('nízké', 'vysoké'), pch=c(1, 16, 1, 1), bty='n',
horiz=T, inset=c(0, -.25), xpd=T)
legend('topright', c('<50 m', '<100 m', '<200 m', '>200 m'), pch=1, bty='n', horiz=T,
text.width=strwidth('>200 m') * 1.2,
pt.cex=c(1, 2, 3, 4), y.intersp=1.6, x.intersp=1.3, inset=-c(.01, .3), xpd=T)
mtext(side=1, x.axis, line=2.2, cex=.7)
mtext(side=2, 'četnost zmlazení', line=2.2, cex=.7)
par(mar=c(2.5, 3, 2, 0.3))
}
}
dev.off()
}
plotVariable(soil$ca, 'ca-spe.pdf', 'Ca')
plot(1)
plotVariable(soil$ca, 'ca-spe.pdf', 'Ca')
plotVariable(soil$ca, 'ca-spe.pdf', 'Ca', log='y')
tree.labels
tree.labels['ac']
tree.labels['Acer campestre']
tree.names
tree.labels[tree.names['ac']]
plotVariable <- function(var, file.name, x.axis, log='') {
pdf(file.eda(file.name), height=11, width=7.5, paper='a4')
par(mfrow=c(6,1), mar=c(4, 3, 2, .3))
for (i in c('ac', 'cb', 'fx', 'q', 'rp', 'tc')) {
values.high.which <- which(unlist(gener.130[paste0(i, '.sum')]) > 0)
values.high <- unlist(gener.130[paste0(i, '.sum')])[values.high.which]
values.low <- unlist(gener.small[paste0(i, '.sum')])
values.closest <- unlist(trees.closest[i])
plot(c(var[order(values.low)], var[values.high.which]),
c(sort(values.low), values.high) + (log!=''),
xlab='', ylab='',
log=log,
#pch=c(rep(1, length(values.low)), rep(16, length(values.high))),
pch=as.numeric(c(plocha[order(values.low)], plocha[values.high.which])),
#cex=range01(c(values.closest[order(values.low)], values.closest[values.high.which]))*3 + 1,
cex=distanceClass(c(values.closest[order(values.low)], values.closest[values.high.which])),
col=grayIfZero(c(sort(values.low), values.high)),
main=tree.labels[tree.names[i]])
if(i=='ac') {
legend('topleft', c('nízké', 'vysoké'), pch=c(1, 16, 1, 1), bty='n',
horiz=T, inset=c(0, -.25), xpd=T)
legend('topright', c('<50 m', '<100 m', '<200 m', '>200 m'), pch=1, bty='n', horiz=T,
text.width=strwidth('>200 m') * 1.2,
pt.cex=c(1, 2, 3, 4), y.intersp=1.6, x.intersp=1.3, inset=-c(.01, .3), xpd=T)
mtext(side=1, x.axis, line=2.2, cex=.7)
mtext(side=2, 'četnost zmlazení', line=2.2, cex=.7)
par(mar=c(2.5, 3, 2, 0.3))
}
}
dev.off()
}
plotVariable(soil$ca, 'ca-spe.pdf', 'Ca', log='y')
names(tree.names)
tree.labels[tree.names['q']]
plotVariable <- function(var, file.name, x.axis, log='') {
pdf(file.eda(file.name), height=11, width=7.5, paper='a4')
par(mfrow=c(6,1), mar=c(4, 3, 2, .3))
for (i in c('ac', 'cb', 'fx', 'q', 'rp', 'tc')) {
values.high.which <- which(unlist(gener.130[paste0(i, '.sum')]) > 0)
values.high <- unlist(gener.130[paste0(i, '.sum')])[values.high.which]
values.low <- unlist(gener.small[paste0(i, '.sum')])
values.closest <- unlist(trees.closest[i])
plot(c(var[order(values.low)], var[values.high.which]),
c(sort(values.low), values.high) + (log!=''),
xlab='', ylab='',
log=log,
#pch=c(rep(1, length(values.low)), rep(16, length(values.high))),
pch=as.numeric(c(plocha[order(values.low)], plocha[values.high.which])),
#cex=range01(c(values.closest[order(values.low)], values.closest[values.high.which]))*3 + 1,
cex=distanceClass(c(values.closest[order(values.low)], values.closest[values.high.which])),
col=grayIfZero(c(sort(values.low), values.high)),
main=tree.labels[which(names(tree.names)==i)]
if(i=='ac') {
legend('topleft', c('nízké', 'vysoké'), pch=c(1, 16, 1, 1), bty='n',
horiz=T, inset=c(0, -.25), xpd=T)
legend('topright', c('<50 m', '<100 m', '<200 m', '>200 m'), pch=1, bty='n', horiz=T,
text.width=strwidth('>200 m') * 1.2,
pt.cex=c(1, 2, 3, 4), y.intersp=1.6, x.intersp=1.3, inset=-c(.01, .3), xpd=T)
mtext(side=1, x.axis, line=2.2, cex=.7)
mtext(side=2, 'četnost zmlazení', line=2.2, cex=.7)
par(mar=c(2.5, 3, 2, 0.3))
}
}
dev.off()
}
plotVariable <- function(var, file.name, x.axis, log='') {
pdf(file.eda(file.name), height=11, width=7.5, paper='a4')
par(mfrow=c(6,1), mar=c(4, 3, 2, .3))
for (i in c('ac', 'cb', 'fx', 'q', 'rp', 'tc')) {
values.high.which <- which(unlist(gener.130[paste0(i, '.sum')]) > 0)
values.high <- unlist(gener.130[paste0(i, '.sum')])[values.high.which]
values.low <- unlist(gener.small[paste0(i, '.sum')])
values.closest <- unlist(trees.closest[i])
plot(c(var[order(values.low)], var[values.high.which]),
c(sort(values.low), values.high) + (log!=''),
xlab='', ylab='',
log=log,
#pch=c(rep(1, length(values.low)), rep(16, length(values.high))),
pch=as.numeric(c(plocha[order(values.low)], plocha[values.high.which])),
#cex=range01(c(values.closest[order(values.low)], values.closest[values.high.which]))*3 + 1,
cex=distanceClass(c(values.closest[order(values.low)], values.closest[values.high.which])),
col=grayIfZero(c(sort(values.low), values.high)),
main=tree.labels[which(names(tree.names)==i)])
if(i=='ac') {
legend('topleft', c('nízké', 'vysoké'), pch=c(1, 16, 1, 1), bty='n',
horiz=T, inset=c(0, -.25), xpd=T)
legend('topright', c('<50 m', '<100 m', '<200 m', '>200 m'), pch=1, bty='n', horiz=T,
text.width=strwidth('>200 m') * 1.2,
pt.cex=c(1, 2, 3, 4), y.intersp=1.6, x.intersp=1.3, inset=-c(.01, .3), xpd=T)
mtext(side=1, x.axis, line=2.2, cex=.7)
mtext(side=2, 'četnost zmlazení', line=2.2, cex=.7)
par(mar=c(2.5, 3, 2, 0.3))
}
}
dev.off()
}
plotVariable(soil$ca, 'ca-spe.pdf', 'Ca', log='y')
plotVariable(soil$ca, 'ca-spe.pdf', 'Ca', log='y')
plot(1)
plotVariable(soil$ca, 'ca-spe.pdf', 'Ca', log='y')
for (var in 1:8) {
plotVariable(soil[, var+5], paste0(names(soil)[var+5], '-spe-log.pdf', col.labels[var], log='y')
}
plotVariable(humid$humid, 'humid-spe-log.pdf', 'vlhkost', log='y')
plotVariable(trees.plot$cover, 'light-spe-log.pdf', 'pokryvnost stromového patra', log='y')
dev.off()
plot(1)
for (var in 1:8) {
plotVariable(soil[, var+5], paste0(names(soil)[var+5], '-spe-log.pdf'), col.labels[var], log='y')
}
plotVariable(humid$humid, 'humid-spe-log.pdf', 'vlhkost', log='y')
plotVariable(trees.plot$cover, 'light-spe-log.pdf', 'pokryvnost stromového patra', log='y')
plot(gener.small$q.cover + gener.130$q.cover ~ veget$q.130.cover)
plot(veget$q.130.cover ~ trees.plot$cover)
plot(veget$q.small.cover ~ trees.plot$cover)
plot(veget$q.m.cover ~ trees.plot$cover)
plot(veget$cb.130.cover ~ trees.plot$cover)
setwd('/media/Data/skola/dipl/data/csv/primary/')
#setwd('D:/Dropbox/skola/dipl/data/csv/primary/')
outputDir <- '../working'
trees.with.juvs <- c("cb", "q", "st", "tc")
missing <- data.frame(plocha=rep('BUD', 3),
treatment=c('B', 'C', 'C'),
opakovani=c(5, 3, 4))
plot.ids <- c("BUD-A1", "BUD-A2", "BUD-A3", "BUD-A4", "BUD-A5", "BUD-B1",
"BUD-B2", "BUD-B3", "BUD-B4", "BUD-C1", "BUD-C2", "BUD-C5", "CK-A1",
"CK-A2", "CK-A3", "CK-A4", "CK-A5", "CK-B1", "CK-B2", "CK-B3",
"CK-B4", "CK-B5", "CK-C1", "CK-C2", "CK-C3", "CK-C4", "CK-C5",
"KB-A1", "KB-A2", "KB-A3", "KB-A4", "KB-A5", "KB-B1", "KB-B2",
"KB-B3", "KB-B4", "KB-B5", "KB-C1", "KB-C2", "KB-C3", "KB-C4",
"KB-C5", "M-A1", "M-A2", "M-A3", "M-A4", "M-A5", "M-B1", "M-B2",
"M-B3", "M-B4", "M-B5", "M-C1", "M-C2", "M-C3", "M-C4", "M-C5",
"V8-A1", "V8-A2", "V8-A3", "V8-A4", "V8-A5", "V8-B1", "V8-B2",
"V8-B3", "V8-B4", "V8-B5", "V8-C1", "V8-C2", "V8-C3", "V8-C4",
"V8-C5", "V9-A1", "V9-A2", "V9-A3", "V9-A4", "V9-A5", "V9-B1",
"V9-B2", "V9-B3", "V9-B4", "V9-B5", "V9-C1", "V9-C2", "V9-C3",
"V9-C4", "V9-C5")
headers <- read.table('juice_header.txt', header=F)
names(headers) <- c('table.number', 'releve.number', 'plot', 'date',
'cover.tree', 'cover.shrub', 'cover.herb', 'veg',
'gen', 'treat', 'triplet', 'spe.num')
row.names(headers) <- sub('Č', 'C', headers$plot)
spe <- read.csv('releves.csv', sep='\t')
headers
str(spe)
head(str(spe))
str(spe[, 1:10])
rstudio::viewData(spe)
headers <- read.table('juice_header.txt', header=F)
headers
