Learn R Programming

PriceIndices (version 0.0.7)

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",
  space = 1
)

Value

The function returns the user's data frame with two additional columns: grammage and unit (both are character type). 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

multiplication

A sign of the multiplication used in product descriptions

space

A maximum space between the product grammage and its unit

Examples

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

Run the code above in your browser using DataLab