Topic: Utilities
Topic Description:
Basic R utilities used in many packages and functions, such as date and string manipulations, statistical distributions, geometry of lines and distances. The R package date is required for the two data functions.
File: utilities/utilities.r
| View File Source | Download File | No help file available |
Function: fill.dimension
Function Description: fill.dimension
This function fills out an array of 2 dimensions, adding zeroes (or other values) for extra columns and rows as named in class1 and class2. If a column (or row) is missing, it will be filled with the value given by fill. It is useful for results of table or tapply when some elements had no records.Function Arguments:
| Argument | Default Value |
|---|---|
| dataarray | |
| class1 | |
| class2 | |
| fill | 0 |
Function Source:
fill.dimension=function(dataarray,class1,class2,fill=0)
{
result=data.frame(matrix(fill,nrow=length(class1),ncol=length(class2)))
rownames(result)=class1
colnames(result)=class2
result[rownames(dataarray),colnames(dataarray)]=dataarray
result[is.na(result)]=fill
return(result)
}
{
result=data.frame(matrix(fill,nrow=length(class1),ncol=length(class2)))
rownames(result)=class1
colnames(result)=class2
result[rownames(dataarray),colnames(dataarray)]=dataarray
result[is.na(result)]=fill
return(result)
}