numberForLevelsAddTable: numberForLevelsAddTable

Description Usage Arguments Value Examples

View source: R/numberForLevelsAddTable.R View source: R/numbersForLevelsAddTable.R

Description

numberForLevelsAddTable takes as input a data.frame object (dfData), a character vector containg column names (dfColNameVec), a list of numeric vectors (vecList), a name for the output data.frame object (outputDfName) and the storage path (outputDir). The output is a data.frame object and a .xlsx file containing new columns with numbered levels. The outputs are stored at the location specified by the storage path.

Usage

1
numberForLevelsAddTable(dfData, dfColNameVec, vecList, outputDfName, outputDir)

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

dfColNameVec

a string or a vector of class character indicating the name(s) of the column(s) of dfData whose levels have to be numbered.

vecList

a numeric vector or a list of numeric vectors. Each vector contains numbers that are to be assigned to the levels of the respective column. The number of vectors in the list should be equal to the number of column names in dfColNameVec. The nth list corresponds to the nth column name.

outputDfName

a character string indicating the name of the output data.frame object

outputDir

a character string indicating the storage path for the output .xlsx file

Value

numberForLevelsAddTable returns a data.frame object and an xlsx file containing a column for each column in dfColNameVec. In every new column the entries of the corresponding original column are replaced by numbers (as specified by vecList) assigned to the levels for each column. Additionally, it also prints the output data.frame object in the console window.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
numberForLevelsAddTable(mainTable,c("col1","col2"),
                        list(c(0,4,3),c(0,1,1.5,2,3)),
                        "newTabName","D:/FolderName/")
numberForLevelsAddTable(warpbreaks,c("wool","tension"),
                        list(c(1:2),c(1,5,10)),
                        "df_numberForLevelsAddTable",
                        "D:/Work/")
numberForLevelsAddTable(iris,"Species",c(1:3),
                       "df_numberForLevelsAddTable2",
                       "D:/Work/")

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