R/sementes_function.R

Defines functions sementes

Documented in sementes

#' Germination or emergency index (IVG,IVE,TMG e TME)
#'
#' Seeds
#' @description The seed function calculates the average time and the emergence or germination speed index according to the methodology of Maguire (1962).
#' @param dados Data.frame composed of the answers in each time in columns.
#' @param tempo Numeric vector with time
#' @param trat Vector with the names of the treatments with the repetitions
#' @author Gabriel Danilo Shimizu
#' @references MAGUIRE, J.D. Speed of germination aid in selection and evaluation for seedling emergence and vigor. Crop Science, Madison, v.2, n.2, p.176-77, 1962.
#' @import xlsx
#' @keywords IVE
#' @keywords TMG
#' @keywords Index
#' @export
#' @examples
#' dia7=c(0,2,1, 4,5,6, 2,3,2)
#' dia14=c(4,5,6, 8,9,8, 14,15,16)
#' dia21=c(14,20,16, 25,26,28, 30,31,33)
#' dia28=c(30,35,32, 40,41,44, 46,48,50)
#' dia35=c(45,47,50, 48,49,50, 50,50,49)
#' dados=data.frame(dia7,dia14,dia21,dia28,dia35)
#' trat=rep(c("T1","T2","T3"),e=3)
#' tempo=c(7,14,21,28,35)
#' sementes(dados,tempo,trat)


sementes=function(dados, tempo, trat,  save=FALSE){
  d=data
  t=tempo
  ndata=length(tempo)
  i=ndata
  tempo=data.frame(matrix(rep(t[rep(1:i,e=length(d[,1]))],e=length(rownames(d))),nrow = length(rownames(d))))
  dnovo=cbind(d[,1],d[,2:i]-d[,1:i-1])
  iv=rowSums(dnovo/tempo)
  tm=rowSums(data.frame(d[,1]*t[1],(d[,2:i]-d[,1:i-1])*t[rep(2:i,e=length(d[,1]))]))/d[,i]
  colnames(tm)="tm"
  #v=rowSums(data.frame(dnovo[,1]*t[1],(dnovo[,2:i])*t[rep(2:i,e=length(dnovo[,1]))]))/sum(t)
  vg=rowSums(dnovo*tempo)/rowSums(dnovo)
  cvg=rowSums(dnovo)/rowSums(dnovo*tempo)*100
  pive = data.frame(trat, iv, tm,vg,cvg)
  print(pive)
  if(save==TRUE){xlsx::write.xlsx(pive, "Planilha.xlsx")}
}
AgronomiaR/iagro documentation built on April 16, 2020, 10:54 p.m.