## ----wofost_wth_0------------------------------------------------------------- library(Rwofost) f <- system.file("extdata/Philippines_IRRI.csv", package="meteor") basename(f) ## ----wofost_wth_10------------------------------------------------------------ w <- read.csv(f) head(w) ## ----wofost_wth_20------------------------------------------------------------ sapply(w, class) ## ----wofost_wth_30------------------------------------------------------------ w$date <- as.Date(w$date) ## ----wofost_wth_35, echo=FALSE------------------------------------------------ m <- matrix(c("date", "'Date'", "–", "srad", "Solar radiation", "kJ m-2 day-1", "tmin", "Minimum temperature", "°C", "tmax", "Maximum temperature", "°C", "vapr", "Vapor pressure", "kPa", "wind", "Wind speed", "m s-1", "prec", "Precipitation", "mm day-1"), ncol=3, byrow=TRUE) colnames(m) <- c("variable", "description", "unit") knitr::kable(m) ## ----wofost_wth_40------------------------------------------------------------ nrow(w) head(w) tail(w) ## ----wofost_wth_50------------------------------------------------------------ w[nrow(w), "date"] - w[1, "date"] nrow(w) ## ----wofost_wth_60, error=TRUE------------------------------------------------ d <- diff(w$date) all(d == 1) ## ----wofost_wth_70------------------------------------------------------------ table(d) i <- which(d > 1) w[i:(i+1), ] ## ----wofost_wth_80------------------------------------------------------------ degC <- function(F) 5 * (F - 32) / 9 dF <- 0:110 dC <- degC(dF) plot(dF, dC) abline(h=0) abline(v=32)