Learn R Programming

PriceIndices (version 0.2.3)

data_unit: Providing information about the grammage and unit of products

Description

The function returns the grammage and unit of products as two additional columns.

Usage

data_unit(data = data.frame(), units = c("g|ml|kg|l"), multiplication = "x")

Value

The function returns the user's data frame with two additional columns: grammage and unit. The values of these columns are extracted from product descriptions on the basis of provided units. Please note, that the function takes into consideration a sign of the multiplication, e.g. if the product description contains: '2x50 g', we obtain: grammage: 100 and unit: g for that product (for multiplication set to 'x').

Arguments

data

The user's data frame. The data frame must contain the description column (as character).

units

Units of products which are to be detected (e.g. "ml|g|kg")

multiplication

A sign of the multiplication used in product descriptions (e.g. "x")

Examples

Run this code
data_unit(dataU, units=c("g|ml|kg|l"), multiplication="x")

Run the code above in your browser using DataLab