plot3Var: plot3Var

Description Usage Arguments Value Examples

View source: R/plot3Var.R

Description

plot3Var takes as input a data.frame object (dfData), three column names (plotVar1, plotVar2, plotVar3), three character strings (firstAxis, secondAxis, thirdAxis)specifying the axis labels to be used respectively for the three y-axis, a character string indicating the name of the ordering variable (should be one of - plotVar1, plotVar2, plotVar3), a character string (main) for the overall title of the plot, 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, and a boolean variable indicating whether to save a copy of the plot as a .png file. It then generates a plot from three variables and for copy == T, saves the plot as a .png file in the "plot" directory within the current working directory. If the directory called "plot" is not present in the current working directory, a new directory called "plot" is created.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
plot3Var(
  dfData,
  plotVar1,
  firstAxis = expression(Yield ~ (Kg ~ ha^-1)),
  orderVar,
  ylim1,
  scaleFVar3,
  plotVar2,
  secondAxis,
  secYaxStep,
  ylim2,
  plotVar3,
  thirdAxis,
  trdYaxStep,
  subDir,
  main = NULL,
  width = 1000,
  height = 600,
  res = 125,
  copy = F,
  idVar = NULL
)

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 (" ").

plotVar1

a character string indicating the name of the column from data.frame object dfData to be plotted.

firstAxis

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

orderVar

a character string indicating the name of the ordering variable. It is one of the three variables used to create the plot - plotVar1, plotVar2, plotVar3

ylim1

a numeric vector containing two values indicating the lower and upper limits of the first y-axis.

scaleFVar3

a number indicating how much the third y-axis be scaled compared to the first two y-axes.

plotVar2

a character string indicating the name of the column from data.frame object dfData to be plotted.

secondAxis

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

secYaxStep

a number indicating the difference between consecutive tick values for the second y-axis.

ylim2

a numeric vector containing two values indicating the lower and upper limits of the second y-axis.

plotVar3

a character string indicating the name of the column from data.frame object dfData to be plotted.

thirdAxis

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

trdYaxStep

a number indicating the difference between consecutive tick values for the third y-axis.

subDir

a character string indicating the name of the subdirectory within "output" and "plot" directories 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/.

main

a character string indicating an overall title for the plot.

width

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

height

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

res

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

copy

a boolean variable (default: F) indicating whether to save the plot as a .png file or not.

idVar

a positive integer indicating the column number of the column in the data.frame object dfData to be used for inserting text in the output plot.

Value

plot3Var returns a plot of 3 variables (plotVar1, plotVar2, plotVar3) from the data.frame object dfData and saves the plot as a .png file in the "plot" directory within the current working directory. If the directory called "plot" is not present in the current working directory, a new directory called "plot" is created.

Examples

1
2
3
4
5
6
7
8
 plot3Var(dfData=ca_s,plotVar1="yieldWs",
             orderVar="yieldWs",ylim1=c(0,14),scaleFVar3=0.3,
             plotVar2= "nFertWs",
             secondAxis=paste( "N-fert", " (in kg/ha)",sep=""),
             secYaxStep=40,ylim2=c(0,320),plotVar3="paddAreaDs",
             thirdAxis="Area (in ha)",
             trdYaxStep=2,subDir="new",
             main="Ascending amount of N fertilizer vs. Yield",,,,copy=T)

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