mixPlotYield: mixPlotYield

Description Usage Arguments Value Examples

View source: R/mixPlotYield.R

Description

mixPlotYield takes as input a data.frame object (dfData), four character strings indicating the column names from dfData to be used respectively as the y-variable, the x-variable, the first legend, the second legend for the plot. The legend variables are used to color-code the fill and the boundary of the data points in the plot. Other inputs include a character string for the overall title of the plot (main), a character string indicating the name of the output subdirectory (subDir), three positive numbers indicating the width (width), height (height) and resolution (res) of the output plot. It returns a plot of the yield as a function of the organic matter from the data points using varYield and varX as the y and the x variables respectively. The plot is saved as a .png file in the subDir subdirectory within the directory "plot" inside the current working directory. A "plot" directory is created in the current working directory if not present already. Similarly, if subDir is specified, a subdirectory with the name subDir is created within plot/ if not already present, and the plot is saved in that subdirectory. If a subdirectory is not specified (i.e. missing subDir), then the plot is saved in plot/.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
mixPlotYield(
  dfData,
  varYield = "yield",
  varX,
  varTreat,
  varIndex,
  ylab = expression(Yield ~ (Mg ~ ha^-1)),
  ...,
  legend.controlTreat = NULL,
  legend.controlInd = NULL,
  subDir,
  width = 2400,
  height = 1100,
  res = 160
)

Arguments

dfData

a data.frame object. Note that this is not a character string but the data.frame object itself. The parameter passed to the function should be without quotes (" ").

varYield

a character string indicating the name of the column from the data.frame object dfData to be used as the y-variable for the plot. It is a continuous variable.

varX

a character string indicating the name of the column from the data.frame object dfData to be used as the x-variable for the plot. It is a continuous variable.

varTreat

a character string indicating the name of the column from the data.frame object dfData to be used for color-coding the fill of the data points. It serves as the first legend for the plot. It is a categorical variable.

varIndex

a character string indicating the name of the column from the data.frame object dfData to be used for color-coding the boundary of the data points. It serves as the second legend for the plot. It is a continuous variable.

ylab

a character string indicating a label for the y-axis.

legend.controlTreat

a list comprising of legend values and titles for the first legend. (Refer to the examples)

legend.controlInd

a list comprising of legend values and titles for the second legend. (Refer to the examples)

subDir

a character string indicating the name of the subdirectory within the "plot" directory to save the output data.frame object (as a .txt file) and plot (as a .png file)respectively. If a subdirectory with the given name does not exist within output and/or plot, then it is created. If not specified, the outputs are stored in output/ and plot/.

width

a number (default: 2400) indicating the width of the output plot.

height

a number (default: 1100) indicating the height of the output plot.

res

a number (default: 160) indicating the resolution of the output plot.

main

a character string indicating an overall title for the plot.

Value

mixPlotYield returns a plot of the yeild as a function of the organic matter using varYield as the yield variable and varX as the x-variable from the data.frame object dfData with the fill and the boundary color-coded using and columns from dfData. It saves the plot as a .png file in the subDir subdirectory within the directory "plot" inside the current working directory. It creates a "plot" directory in the current working directory if not present already. Similarly, if subDir is specified, it creates a subdirectory with the name subDir within plot/ if not already present, and saves the plot inside the subdirectory. If a subdirectory is not specified (i.e. missing subDir), then it saves the plot in plot/.

Examples

1
2
3
4
5
load("./data/dat0indD_2018.rda")
mixPlotYield(dat0indD_2018,"yield","orgC","treatment",
            "indD",main="Rice yields",xlab="Organic matter (%)",
            legend.controlTreat=list(legend=c(1,2,3,6,7,8,10),title="Treatments"),
            legend.controlInd=list(legend=paste("Int",1:5,sep=""),title="Index Intensity"))

lwTools/agriTrf documentation built on March 26, 2020, 12:09 a.m.