GetDim {cmpp}R Documentation

Get Dimensions of the Cmpp Object

Description

This function returns the number of samples and features stored in the Cmpp object. It is primarily used to retrieve the dimensions of the data within the class.

Usage

GetDim()

Details

The GetDim function allows users to access the internal dimensions of the Cmpp class instance, such as the number of samples (Nsamp) and the number of features (Nfeature). This is useful when working with large datasets, especially for checking the size of the data without needing to manually access the underlying Eigen::MatrixXd or Eigen::VectorXd objects directly.

Value

A list containing:

Nsamp

Number of samples (rows in the feature matrix).

Nfeature

Number of features (columns in the feature matrix).

Examples

# Initialize Cmpp object
library(cmpp)
data("fertility_data")
Nam <- names(fertility_data)
fertility_data$Education
datt <- make_Dummy(fertility_data, features = c("Education"))
datt <- datt$New_Data 
datt['Primary_Secondary'] <- datt$`Education:2`
datt['Higher_Education'] <- datt$`Education:3`
datt$`Education:2` <- datt$`Education:3` <- NULL
datt2 <- make_Dummy(datt, features = 'Event')$New_Data
d1 <- datt2$`Event:2`
d2 <- datt2$`Event:3`
feat <- datt2[c('age', 'Primary_Secondary', 'Higher_Education')] |> 
   data.matrix()
timee <- datt2[['time']]
Initialize(feat, timee, d1, d2, 1e-10)
# Get dimensions
dims <- GetDim()
dims$Nsamp    # Number of samples
dims$Nfeature # Number of features

[Package cmpp version 0.0.2 Index]