db.add {RGeostats}R Documentation

Add vectors to a Data Base


Add one or several vectors to an already existing db-class


db.add(db, ..., locnames=NA, loctype="z", 
auto.locate = FALSE, type.locate=TRUE, flag.replace=FALSE, 
flag.alias=FALSE, flag.number=TRUE, varbase="v", locrank = NA, radix=NA)



The db-class to which vectors must be added


List of the vectors to be added. The vectors are named after their argument names.


List of locators assigned to the newly created variables


Generic name of the locators, only used if the type.locate=TRUE and auto.locate=FALSE


When TRUE, the locators of the new variables are assigned according to the variable name.


When TRUE, the locators of the new variables are generated using 'loctype' combined with the index of the newly created field


When TRUE, any variable with a name similar to the name of one of the added variables is deleted beforehand


Deprecated. Use 'flag.number' instead (with 'radix')


This parameter is only used when 'radix' is provided. When TRUE, the name is composed of the radix followed by the rank of the added variable (within the input argument). When FALSE, the name is simply set to the radix.


Deprecated. Use 'radix' instead (with 'flag.number')


When defined together with the flag type.locate, the added variables receive locators of type loctype, and with a rank starting from locrank.


The new variables can be named automatically if radix is provided. The names are generated according to the following syntax: 'radix'. 'rank' where 'rank' corresponds to the index of the new field.


The '...' argument may contain a series of variables, defined by their names (no quote is required). The variables are added to the data base. An algorithm is then performed to set the locators to these new variables which functions as follows:

If db.add() is used to add a new variable while performing a calculation, all the samples will be processed, regardless of any possible active selection.

If the Db corresponds to a Grid, samples are ordered as described in the 'Details' section of db-class.


The db-class where the vectors have been added

See Also



data(Z_data.db) # Load the Documentation Points Db
Z_data.db # Print a short contents of the Db

# Add a new variable called "New Variable" (set to 0). No locator defined
Z_data.db <- db.add(Z_data.db, New_Variable = 0)
# Note that the quotes (for the variable on the left-side of the '=' sign) 
# are compulsory as the name is the concatenation of two words
# Otherwise, it is optional
# The quotes should not be used on the right of the = sign.
print(Z_data.db) # Print the contents
# The locators are "NA","x1","x2","z1","z2","NA"

# Add one new variable (set to 1) and set its locator explicitely to "z1" 
Z_data.db <- db.add(Z_data.db,z1=1)
print(Z_data.db) 	# Print the contents
# The locators are "NA","x1","x2","NA","z2","NA","z1"

# Add a variable as the result of a calculation on already existing fields
Z_data.db <- db.add(Z_data.db,"Calculated Variable"=z1+2)
# Check the newly created variable is set uniformely to 3
print(Z_data.db,flag.stats=TRUE,name="Calculated Variable")

# Clean up

[Package RGeostats version 11.2.9 Index]