generateMergeLabels: Generate Merge Labels

generateMergeLabels,aquap_data,aquap_data,character,character-methodR Documentation

Generate Merge Labels

Description

Generate an object of class 'aquap_mergeLabels' that can be used to specify the names and values of new variables in the merged dataset.

Usage

## S4 method for signature 'aquap_data,aquap_data,character,character'
generateMergeLabels(ds1, ds2, varNames, varTypes, values = NULL)

## S4 method for signature 'list,missing,character,character'
generateMergeLabels(ds1, ds2, varNames, varTypes, values = NULL)

## S4 method for signature 'list,character,character,list'
generateMergeLabels(ds1, ds2 = NULL, varNames, varTypes, values = NULL)

## S4 method for signature 'list,character,character,missing'
generateMergeLabels(ds1, ds2 = NULL, varNames, varTypes, values = NULL)

Arguments

ds1

An object of class 'aquap_data' or a (possibly named) list containing any number of objects of class 'aquap_data'

ds2

An object of class 'aquap_data'. Is ignored when a list is provided at the argument 'ds1'.

varNames

Character or character vector. The names of the new variables in the merged dataset.

varTypes

Character or character vector, denoting if a new variable is either a class variable or a numerical variable. Two values are possible, 'c' for class variables and 'n' for numerical variables. Provide either a vector the same length as argument 'varNames', or a vector with length one that gets recycled over the length of 'varNames'.

values

A list with the same length as there are new variables, containing the values of the new variables for each dataset to be merged. Can be left at NULL, see details. If a list is provided every element within this list must be the same length as there are numbers of datasets to merge (as for every single dataset for every variable one value must be provided).

Details

Provide either two datasets via the arguments ds1 and ds2, or a list containing any number of datasets at the argument 'ds1'. In the latter case, argument ds2 is ignored. The lengths of the vectors in argument 'varNames' and 'varTypes' have to be the same. Providing a named list at argument 'ds1' leads to these names being displayed as row names in the displayed data frame when inspecting the resulting objet of class 'aquap_mergeLabels', potentially making it easier to assign the values. If the argument 'values' is left at its default NULL, an empty data frame displaying the new variables and possibly the names of the datasets to merge is displayed when inspecting the generated object. The values for each column of this dataframe now can be filled in via standard dataframe subselection. It can be easier to first generate the 'aquap_mergeLabels' object without providing the values, and then, when one can look at the displayed data frame, to fill in the values column by column via standard dataframe subselection. At any checking process (done automatically) the definitions given in argument 'varTypes' are decisive. The last column in the data frame shows the number of observations in each dataset, and it can not be changed manually. It is advised to change the valus exclusively via subsetting the object ("'[,j]<-' or 'object$name <-'). It is advised to name the arguments.

Value

An object of class 'aquap_mergeLabels'.

Note

Naming the input-arguments is advised.

See Also

mergeDatasets

Other dataset modification functions: [,aquap_data-method, calculateVariable(), combineVariable(), mergeDatasets,aquap_data,aquap_data,missing-method

Examples

## Not run: 
fd1 <- gfd()
fd2 <- fd1[1:20] # just create a second dataset
labels <- generateMergeLabels(fd1, fd2, c("foo", "bar", "foobar"), c("c", "n", "c")) 
 labels[,2] <- c(7,8) # manually fill in values for the variable 'bar'
	labels
# now provide values as well
	vlist <- list(c("a", "b"), c(1, 2), c("peter", "paul")) 
labels <- generateMergeLabels(fd1, fd2, c("foo", "bar", "foobar"), c("c", "n", "c"), vlist) 
	labels

## End(Not run)

bpollner/aquap2 documentation built on March 29, 2024, 7:33 a.m.