User Tools

Site Tools


anadat:cs:fun:dotdtf

dtf.dotchart()

Funkce, která udělá dotchart ze všech hodnot dataframu (dtf) naráz. K použití např. při kontrole abundancí druhů v druhové tabulce.

dtf.dotchart<- function(dtf, pch= 16, cex= 0.7, ...){
  n<- nrow(dtf) # get number of rows
  k<- ncol(dtf) # get number of columns
  temp<- stack(dtf) # reshape data into long format
  temp$nr<- as.numeric(temp$ind) + seq(0, 0.8, length= n) # create positions on Y
  vars<- levels(temp$ind) # extract names of variables (species)
 
  plot(nr ~ values, data= temp, type= "n", axes= F, ann= F, ...) # plot an empty plot
  x<- par("usr") # get coordinates of the plot
  rect(x[1], x[3], x[2], x[4], col= "grey90") # draw a grey rectangle
  abline(h= (1:(k+1)) - 0.1, col= "white", ...) # draw lines among variables (species)
  points(nr ~ values, data= temp, pch= pch, cex= cex, ...) # draw the points
  axis(1) # axis X
  axis(2, at = 1:k + 0.4, labels = vars, las= 1, tick = F, ...) # axis Y
}
anadat/cs/fun/dotdtf.txt · Last modified: 2017/04/07 23:51 by vitek