plot2Var: plot2Var

Description Usage Arguments Value Examples

View source: R/plot2Var.R

Description

plot2Var takes as input a data.frame object (dfData), two column names (plotVar1, plotVar2), two character strings (firstAxis, secondAxis)specifying the axis labels to be used respectively for the two y-axis, a character string indicating the name of the ordering variable (should be one of - plotVar1, plotVar2), 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 two 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
plot2Var(
  dfData,
  plotVar1,
  orderVar,
  ylim1,
  scaleFVar3,
  plotVar2,
  secondAxis,
  secYaxStep,
  ylim2,
  subDir,
  main = NULL,
  width = 1000,
  height = 600,
  res = 125,
  copy = F
)

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.

orderVar

a character string indicating the name of the ordering variable. It is one of the two 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.

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.

Value

plot2Var 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
plot2Var(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),
         main="Ascending amount of N fertilizer vs. Yield",copy=T)

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