R/pm_function.R

Defines functions pm

Documented in pm

#' Weight loss
#'
#' Weight loss
#' @description The pm function calculates mass loss over time, this variable being widely used in post-harvest experiments on fruits and vegetables
#' @param dados Data.frame composed of the answers in each time in columns.
#' @param trat Vector with the names of the treatments with the repetitions
#' @param save save of excel
#' @author Gabriel Danilo Shimizu
#' @import xlsx
#' @keywords Weight loss
#' @keywords Index
#' @export
#' @examples
#' dia7=c(45,47,50, 48,49,50, 50,50,49)
#' dia14=c(30,35,32, 40,41,44, 46,48,50)
#' dia21=c(14,20,16, 25,26,28, 30,31,33)
#' dia28=c(4,5,6, 8,9,8, 14,15,16)
#' dia35=c(0,2,1, 4,5,6, 2,3,2)
#' dados=data.frame(dia7,dia14,dia21,dia28,dia35)
#' trat=rep(c("T1","T2","T3"),e=3)
#' tempo=c(7,14,21,28,35)
#' pm(dados,trat)


pm = function(dados, trat,  save=FALSE){
  d=dados
  t=tempo
  ndata=length(tempo)
  i=ndata
  pm=d[,2:i]/d[,1]*100
  pive = data.frame(trat, pm)
  print(pive)
  if(save==TRUE){xlsx::write.xlsx(pive, "Perda de massa.xlsx")}
}
AgronomiaR/iagro documentation built on April 16, 2020, 10:54 p.m.