addOn {GCDkit}R Documentation

Replacing missing data by specified values

Description

Add missing columns ("what") to a matrix "where", fill with "value".

Usage

addOn(what,value=NA,where=WR)

Arguments

what

character or numeric, specifies the column in the matrix where

value

numeric vector with the replacement

where

a matrix in which the replacement is to be done

Details

The function serves two purposes. If a column with the name 'what' does not exist in the numeric data matrix where, it appends a new column and fills it with 'value'.

On the other hand, if the column 'what' does exist, the function attempts to replace only the empty (NA) values by the specified values '(value)'.

Note that by default, no permanent assignment to the original data matrix is done.

Value

Returns the modified version of the matrix where.

Author(s)

Vojtěch Janoušek, vojtech.janousek@geology.cz

Examples

    data(sazava)
    accessVar("sazava")
    
    # The original version of WR not affected
    addOn("MgO/FeO",WR[,"MgO"]/WR[,"FeOt"])
    
    # Permanent assignment 
    WR<-addOn("MgO/FeO",WR[,"MgO"]/WR[,"FeOt"])

[Package GCDkit version 6.1 Index]