Learn R Programming

mldr (version 0.3.22)

mldr_from_dataframe: Generates an mldr object from a data.frame and a vector with label indices

Description

This function creates a new mldr object from the data stored in a data.frame, taking as labels the columns pointed by the indexes given in a vector.

Usage

mldr_from_dataframe(dataframe, labelIndices, attributes, name)

Arguments

dataframe
The data.frame containing the dataset attributes and labels.
labelIndices
Vector containing the indices of attributes acting as labels. Usually the labels will be at the end (right-most columns) or the beginning (left-most columns) of the data.frame
attributes
Vector with the attributes type, as returned by the attributes member of an mldr object. By default the type of the data.frame columns will be used.
name
Name of the dataset. The name of the dataset given as first parameter will be used by default

Value

An mldr object containing the multilabel dataset

See Also

mldr, summary.mldr

Examples

Run this code

library(mldr)

df <- data.frame(matrix(rnorm(1000), ncol = 10))
df$Label1 <- c(sample(c(0,1), 100, replace = TRUE))
df$Label2 <- c(sample(c(0,1), 100, replace = TRUE))
mymldr <- mldr_from_dataframe(df, labelIndices = c(11, 12), name = "testMLDR")

summary(mymldr)

Run the code above in your browser using DataLab