Construct a dataset from a data.frame or a matrix.

Description

The function creates a march.Dataset from a dataframe or a matrix, where each row (resp. column) represents an independent data series when MARGIN is 2 (resp. 1).

Usage

1
2
march.dataset.loadFromDataFrame(dataframe, MARGIN = 2, weights = NA,
  missingDataRep = NA)

Arguments

dataframe

A data.frame containing the dataset.

MARGIN

The dimension of the matrix/data.frame that contains the sequences (resp 1 for the column, 2 for the rows).

weights

If specified, contains the weight of each sequence.

missingDataRep

If specified, the symbol representing a missing data.

Value

A march.Dataset object containing the data contructed from the matrix or data.frame.

Author(s)

Ogier Maitre

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# Create a march dataset from the sleep_df dataframe included in the march package.
sleep <- march.dataset.loadFromDataFrame(sleep_df, MARGIN = 2,
                            weights = NA, missingDataRep = NA)

# Each row of sleep_df contains the data for one subject, so MARGIN was set to 2.

# Most of the subjects have been observed during 7 consecutive years,
# but some subjects have been observed for only 5 or 6 years.
# To load only the first 5 observations of each subject:
sleep.5 <- march.dataset.loadFromDataFrame(sleep_df[,1:5], MARGIN = 2 ,
                            weights = NA, missingDataRep = NA)

# The sleep data are not weighted.
# To add a weighting variable taking value 1.5 for the 500 first subjects
# and value 0.5 for the 500 next:
weighting <- rep(1.5,1000)
weighting[501:1000] <- rep(0.5,500)
sleep.w <- march.dataset.loadFromDataFrame(sleep_df, MARGIN = 2,
                           weights = weighting, missingDataRep = NA)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.