readInXlsxRda: readInXlsxRda

Description Usage Arguments Value Examples

View source: R/readInXlsxRda.R

Description

ReadInXlsxRda is used to read and perform different checks in an xlsx file. It uses the native function loc.col from the package. The first check is performed on the Data columns on the data sheet and the Variable names in the variable sheet for any mismatch and aborts the run if there is any mismatch. An excel report is saved in the file's directory or outputSubdir sub-directory. The excel file consists of 2 sheets "Data-sheet" and "Var-sheet". The "Data-sheet" consists of the DataName and DataLoc with the name of the column and location respectively that doesnt match with the corresponding variable sheet. The "Var-sheet" consists of VarNames and VarLoc with the name of the variable and location respectively that doesnt match with the corresponding data sheet. Loads the "data" or "variable" or both in the global environment based on the value given for the parameter loadPar.Outputs an excel file in the file path (or outputSubdir) with the row number, column number and the column name of the NA or wrong values.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
readInXlsxRda(
  file,
  dataEnd = NULL,
  loadPar = "data",
  data = "data",
  variables = "variables",
  varClass = "varClass",
  varValues = "varValues",
  skip.deprecated = TRUE,
  idCol,
  restParRow = 0.975,
  restParCol = 0.975,
  gcTabs = T,
  outputSubdir = NULL
)

Arguments

file

a character string indicating a the WHOLE PATH leading to a xlsx file. The file should contain the corresponding sheetsfor data and variables.

dataEnd

integer indicating the end row until where the data should be read. If not given reads till the end of the excel file. Default value is NULL

loadPar

string values "data" or "data-var". If invoked with "data", the data is loaded into the global environment and if invoked with "data-var" loads both the Data and Variables in the global environment. Default value is data

data

string indicating the name of the Data sheet in the excel file. Default value is data

variables

string indicating the name of the variable Description sheet in the excel file. Default value is variables.

varClass

string indicating the name of the column in the sheet variables providing the classes of the variables . Default value is varClass.

varValues

string indicating the name of the column in the sheet variables providing the values and IMPORTANTLY factor levels of the variables. Default value is varValues.

skip.deprecated

boolean (TRUE or FALSE) indicating to skip the depricated values or not.Default value is TRUE.

idCol

string indicating the name of the column in the "data" sheet containing numeric values from 1 to n, where n= number of famers/plots.No default value available.

restParRow

numeric. A number between 0 and 1 to indicate the percentage of NA values allowed in a Row in the Date sheed in the excel file. Default value is 0.975.

restParCol

numeric. A number between 0 and 1 to indicate the percentage of NA values allowed in a Column in the Date sheed in the excel file. Default value is 0.975.

gcTabs

boolean (TRUE or FALSE) for R and java garbage collection. Useful when large excel files are read in. The default value is F.

outputSubdir

character string indicating the sub-directory inside the directory where all produced files are saved.

Value

As per the value given for the argument loadPar "data" or "variables" or both will be loaded in the global environment. If the data column names mismatch with the variable name list, an excel file indicating the location and name of the column names that mismatch. If there are any blank or NA values in the data, an excel file indicating the location of the Na values.

Examples

1
2
3
4
readInXlsxRda(file,9,"data-var","data-1","variables-1",2,TRUE,"PATH")
readInXlsxRda(file)
readInXlsxRda(file,10)
readInXlsxRda(file,data="data-sheet",variables="variable-sheet")

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